How to display checkmark in datagrid
Hi ,
I have created a datagrid in Windows Form using C# and .Net . I have rows and columns in that datagrid. One of the column data type is string and it displays it correctly. But under other column I want to display a checkmark ( not a checkbox) . It should be readonly.
I have tried to define it is a bool and set the value to true/false , but it shows 1 or 0 respectively.
Please suggest me a way to do this
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Andrzej WegierskiRank #1,729 · 877 pointsPosted Dec 21, 2005, 11:31 PM EST
Next solution is to modify the DataGridTextColumn to paint checkbox with ControlPaint class:
ButtonState st=(base.Text=="x"?ButtonState.Checked:ButtonState.Normal); if(!this.Enabled) st|=ButtonState.Inactive; ControlPaint.DrawCheckBox(e.Graphics,0,0,Math.Min(this.Width,this.Height)-4, this.Height-4,st);