0
Answer

how to manage the gride scroll

Ask a question
hi all
i create a project in window form and make a datagrideview as the project requirement
now i make gride and make editable grid as per my knowledge which i show u.
in my gride whene click on the cell on gride  i move the  textbox on the particular cell which i have clicked
now i have problem is when more row in gride then gride is scroll down or up now when i clicked on the cell in grid then texbox is move but not go the the clicked cell


when i click on the "c" written cell the text box come over now problem is

in second image the rows are more and click on the cell the textbox is move but not the cell




how to do that the fix problem




and if u dont understand my problem

please give me idea or code how to make editable datagride and where i click on the cell that able to edit and save

thanks

my code is
 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);
}
}
}