Skip to content

Instantly share code, notes, and snippets.

@devmnj
Created September 26, 2022 04:54
Show Gist options
  • Select an option

  • Save devmnj/f55dfe63297b2693407465341f75236d to your computer and use it in GitHub Desktop.

Select an option

Save devmnj/f55dfe63297b2693407465341f75236d to your computer and use it in GitHub Desktop.
How to place textboxes and other control on Datagridview - C#.Net
try
{
int r_left = 0, r_top = 0;
DataGridViewCell cell;
cell = row.Cells[colLno.Index];
r_left = dataGridView1.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, false).Left;
r_top = dataGridView1.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, false).Top;
ctxt_lno.Width = cell.Size.Width;
ctxt_lno.Height = cell.Size.Height;
ctxt_lno.Top = r_top + dataGridView1.Top;
ctxt_lno.Left = r_left + dataGridView1.Left;
ctxt_lno.Text = cell.Value != null ? cell.Value.ToString() : (row.Index + 1).ToString();
}
catch (Exception)
{
throw;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment