Grid View Column
-
i create control and this control derived from gridview control.then i add 2 column in constructor like this : InitializeComponent(); this.AutoGenerateColumns = false; DataGridViewCheckBoxColumn cb = new DataGridViewCheckBoxColumn(); cb.HeaderText = ""; cb.Name = "dgvcSelect"; this.Columns.Add(cb); DataGridViewTextBoxColumn tb = new DataGridViewTextBoxColumn(); tb.Name = "dgvcRowNumber"; tb.HeaderText = "ردیف"; but when i run my program 4 column generate for me.where is the problem? please help me
-
i create control and this control derived from gridview control.then i add 2 column in constructor like this : InitializeComponent(); this.AutoGenerateColumns = false; DataGridViewCheckBoxColumn cb = new DataGridViewCheckBoxColumn(); cb.HeaderText = ""; cb.Name = "dgvcSelect"; this.Columns.Add(cb); DataGridViewTextBoxColumn tb = new DataGridViewTextBoxColumn(); tb.Name = "dgvcRowNumber"; tb.HeaderText = "ردیف"; but when i run my program 4 column generate for me.where is the problem? please help me
Did you turn AutoGenerateColumns back on in your code consuming this new control? Do your column names match the column names coming from your bound data?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Did you turn AutoGenerateColumns back on in your code consuming this new control? Do your column names match the column names coming from your bound data?
A guide to posting questions on CodeProject[^]
Dave Kreskowiaksome column come from database but these 2 column generate at runtime.i think thic part of code call twice.what can i do when i have custom control and want generate columns at runtime?
-
some column come from database but these 2 column generate at runtime.i think thic part of code call twice.what can i do when i have custom control and want generate columns at runtime?
If you think that's the case, then call the Clear method of the Columns collection at the start of your code that setups up your columns.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
i create control and this control derived from gridview control.then i add 2 column in constructor like this : InitializeComponent(); this.AutoGenerateColumns = false; DataGridViewCheckBoxColumn cb = new DataGridViewCheckBoxColumn(); cb.HeaderText = ""; cb.Name = "dgvcSelect"; this.Columns.Add(cb); DataGridViewTextBoxColumn tb = new DataGridViewTextBoxColumn(); tb.Name = "dgvcRowNumber"; tb.HeaderText = "ردیف"; but when i run my program 4 column generate for me.where is the problem? please help me
Please find this example. write the select query what ever the colums you want to display in datagridview http://www.dotnetsharepoint.com/2013/07/display-data-in-datagridview-c.html#.UfEm342fjwg[^]