how to add column dynamically in datagridview using c#
On click of start new examination a new column should be added to grid to enter examination data against measurement variable. Same way user can add another new column to record examination details on click of "New examination" button.
TextBox TextBox1 = new TextBox(); GridView1. Rows[0]. Cells[0].
) on the upper-right corner of the DataGridView control, and then select Add Column. In the Add Column dialog box, choose the Databound Column option and select a column from the data source, or choose the Unbound Column option and define the column using the fields provided.
For example:
DataGridViewColumn col = new DataGridViewTextBoxColumn();
col.HeaderText = "Hi there";
int colIndex = grid.Columns.Add(col);
If it's like any of the other .Net grid controls:
YourDataGridView.Columns.Add(New DataGridViewColumn());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With