We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How do I hide particular checkboxes in a datagrid column?

Hi, I have a DataGrid bound to a table with 5 columns and 20 rows. Out of 5 columns, the first one is of custom type public class DataGridCheckBoxColumn : DataGridBoolColumn {}; the rest 4 columns are of type DataGridTextBoxColumn. My first column needs to be able to hide checkboxes based on the rowNum. I was able to make them uneditable by overriding the Edit()method, but how do I make them invisible? I tried overriding Paint() method, but it didn't work for me: protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, bool alignToRight) { if (rowNum == 1) { Brush bgBrush = new SolidBrush(this.DataGridTableStyle.BackColor); Brush fgBrush = new SolidBrush(this.DataGridTableStyle.ForeColor); g.FillRectangle (bgBrush, bounds); } else base.Paint(g, bounds, source, rowNum, alignToRight); } I would appreciate any suggestions on how I might be able to hide/make invisible certain checkboxes. Thanks so much! Natalia

Loader.
Live Chat Icon For mobile
Up arrow icon