Skip to content

Adding multiple controls in DataGridViewColumn

web

Asked Dec 13, 2006, 9:42 AM EST1 answer
Share
LinkedInX
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); } }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    That's really horrible to read, a few line breaks wouldn't go amiss.
    0