1
Answer

adding multiple controls in DataGridViewColumn

web

web

18y
4.1k
1
Hi All, Ive trying to create a custom datagridview where one customized column could contain checkBox, textBox, or even listboxes. I know I would have to override the dataGridViewCell class, but how to I add a control to the cell i.e. If i want to create a customized DataGridviewCell where the cells contain checkboxes? My code below show display checkboxes, but it doesnt.... Any help would be appreciated, Thanks Here's the paint method in my class: public class DataGridViewCustoomizedCell : DataGridViewCell{ protected override void Paint( Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { // Call the base class method to paint the default cell appearance. CheckBox chk = new CheckBox(); chk.Text = "hehe"; base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, chk, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); } }
Answers (1)