This is a migrated thread and some comments may be shown as answers.

Formatting a Cell to Hexa

1 Answer 138 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hana Yahia
Top achievements
Rank 1
Hana Yahia asked on 02 Jul 2013, 07:48 AM
I wanna format a column in the grid to hexa decimal , i tried to set the formatstring property to {0,X} but it doesn't work  

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 04 Jul 2013, 07:39 AM
Hello Hana,

Thank you for writing.

Here is an example of how to format the grid column values as hexadecimal:
public Form1()
{
    InitializeComponent();
 
    GridViewDecimalColumn col = new GridViewDecimalColumn();
    col.Name = "numCol";
    col.Width = 200;
    col.FormatString = "{0:X}";
    col.DataType = typeof(int);
    radGridView1.Columns.Add(col);
    radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
}
 
void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    if (e.Column.Name == "numCol")
    {
        GridSpinEditor editor = (GridSpinEditor)e.ActiveEditor;
        GridSpinEditorElement element = ((GridSpinEditorElement)editor.EditorElement);
        element.Hexadecimal = true;
        element.MinValue = 0;
        element.MaxValue = 65535;
        element.TextBoxControl.MaxLength = 4;
    }
}

I hope that you find it useful.

P.S. The other thread you have submitted regarding the same matter was deleted.

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Hana Yahia
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or