Formatting a Cell to Hexa

2 posts, 1 answers
  1. Hana Yahia
    Hana Yahia  avatar
    1 posts
    Member since:
    Jun 2013

    Posted 02 Jul 2013 Link to this post

    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  
  2. Answer
    Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 04 Jul 2013 Link to this post

    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 >>
Back to Top