// overview of data in adi metroGrid1 website dedicated to the website dedicated to the bulunan website // tabular in alt-jazzy word the word "document of kullan bilirsiniz"
private void metroGrid1_CellMouseClick (object sender, DataGridViewCellMouseEventArgs e) {
if (e.Button == MouseButtons.Right)
{
ContextMenu m = new ContextMenu();
m.MenuItems.Add("Kopyala", new EventHandler(kopyala_Click));
m.MenuItems.Add("Yapıstır", new EventHandler(Yapıstır_Click));
int currentMouseOverRow = metroGrid1.HitTest(e.X, e.Y).RowIndex;
if (currentMouseOverRow >= 0)
{
m.MenuItems.Add(new MenuItem(string.Format("Do something to row {0}", currentMouseOverRow.ToString())));
}
m.Show(metroGrid1, new Point(e.X, e.Y));
}
}
private void Yapıstır_Click(object sender, EventArgs e)
{
string s = Clipboard.GetText();
string[] lines = s.Split('\r','\n','\t');
int row = metroGrid1.CurrentCell.RowIndex;
int col = metroGrid1.CurrentCell.ColumnIndex;
int cellsSelected = lines.Length;
if (row < metroGrid1.Rows.Count)
{
for (int i = 0; i < cellsSelected; i++)
{
if (col + i < metroGrid1.Columns.Count)
{
if (lines[i] != "")
{
metroGrid1[col + i, row].Value = lines[i];
}
else
{
col -= 1;
}
}
else
{break; }
}
row++;
}
}
source
share