I have a datagridview with multiple table adapters. every click on the dg exposes a new table on the same control.
How can i show different columns on click?
I’ve tried to use
DataGridViewColumn newCol = new DataGridViewColumn();
DataGridViewCell cell = new DataGridViewTextBoxCell();
newCol.CellTemplate = cell;
newCol.HeaderText = "numOfTexts";
newCol.Name = "numOfTexts";
newCol.Visible = true;
dg1.Columns.Add(newCol);
but it doesn’t display the cell content, only the column name.
Thanks
You can use:
dg.AutoGenerateColumns = true;See MSDN
This is exactly what you need to display all columns of the table adapter.
You can hide the unnecessary columns.
Hope I helped…