Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic columns checkbox

Status
Not open for further replies.

newbie14

Technical User
Feb 14, 2009
81
MY
Dear All,
For now I have a datagrid with just one column of checkbox. I normally first called a function design grid and below is my code

gridAuthorization.AutoGenerateColumns = false;
gridAuthorization.Columns.Add("subMenu1ID","");
gridAuthorization.Columns[0].Visible = false;gridAuthorization.Columns.Add("subMenu1Name","Sub Menu Name");
gridAuthorization.Columns[1].ReadOnly = true;
gridAuthorization.Columns[1].Width = 200;
DataGridViewCheckBoxColumn cbSelect = new DataGridViewCheckBoxColumn();
{
cbSelect.HeaderText = "Select";
cbSelect.AutoSizeMode =
DataGridViewAutoSizeColumnMode.AllCells;
cbSelect.DisplayIndex = 8;

}
gridAuthorization.Columns.Add(cbSelect);
Then I call a function called as populateGrid and I run my select statements and accoridingly I will call the gridAuthorization.Rows.Add and accordingly add the rows.

The problem now I want another datagrid where the columns of checkbox should be dynamic like maybe first row only have 2 columns third row may have 4 columns etc.
For example my select column1,column2,column3,column4 from tblSubMenu. So I want to see if my column1 has a value then I want to put the checkbox and accordingly for other columns. Is this possible?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top