private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
int x,y;
if(dataGrid1.CurrentRowIndex != - 1)
{
x = dataGrid1.Left;
y = dataGrid1.Top;
textBox1.Width = dataGrid1.GetCellBounds(dataGrid1.CurrentCell).Width;
textBox1.Height = dataGrid1.GetCellBounds(dataGrid1.CurrentCell).Height;
textBox1.Left = dataGrid1.GetCellBounds(dataGrid1.CurrentCell).Left + x;
textBox1.Top = dataGrid1.GetCellBounds(dataGrid1.CurrentCell).Top + y;
textBox1.Text = dataGrid1[dataGrid1.CurrentCell.RowNumber,dataGrid1.CurrentCell.ColumnNumber].ToString().Trim();
textBox1.Visible = true;
textBox1.Focus();
}
else
{
textBox1.Visible = false;
}
}