private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int x; int y; int i = dataGridView1.SelectedCells[0].RowIndex; int j = dataGridView1.SelectedCells[0].ColumnIndex; textBox1.Text = dataGridView1.Rows[i].Cells[j].Value.ToString(); label1.Text = Convert.ToString(i); label2.Text = Convert.ToString(j); int col = dataGridView1.ColumnCount; int row = dataGridView1.RowCount; label5.Text = Convert.ToString(col); label6.Text = Convert.ToString(row); //x = 43; //y = 21; //x = (i + 1) * 100; //y = (j + 1) * 20; if (j == 0) { x = 42; if (i == temp) { y = 22 * (1 + i); temp = 0; textBox1.Location = new Point(x, y); } else if (i > temp) { y = 22 * (i + 1); temp = i; textBox1.Location = new Point(x, y); } else if (i < temp) { y = 22 * (i + 1); temp = i; textBox1.Location = new Point(x, y); } } else if (j == 1) { x = 42 + 100; if (i == temp1) { y = 22 * (1 + i); temp1 = 0; textBox1.Location = new Point(x, y); } else if (i > temp1) { y = 22 * (i + 1); temp1 = i; textBox1.Location = new Point(x, y); } else if (i < temp1) { y = 22 * (i + 1); temp1 = i; textBox1.Location = new Point(x, y); } }}