Skip to content

How to display checkmark in datagrid

Neeraj

Asked Dec 21, 2005, 7:06 PM EST1 answer
Share
LinkedInX
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.

  • 0
    Try to find the proper font with checkmark. Use it in datacolumn style. Use string column with proper signs. But ... I tried to find it (in usual fonts) and couldn't do it. Now I use space to false and simple "x" in Verdana to true.
    Next solution is to modify the DataGridTextColumn to paint checkbox with ControlPaint class:
    C#
    
    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);
    0