Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
295
Switching Field Format between DEC and HEX
posted

Hi there,

using the latest IG version, i want to achieve 2 things on a XamDataGrid Field with AlternateBinding to a UInt32

1) During runtime i want to be able to switch between decimal and hexadecimal display, e.g. the Field should display either "256" or "0x100"

2) I want to be able to either input in decimal or ind hexdecimal style, depending on the way the field currently displays the number.

Is there a way to do this with XamdataGrid. At this time i only can display the "256" as "100" , not with the precceding "0x", and i cannot input A to F, which would be required.

I appreciate your help

Thanks

Thomas

  • 2680
    Offline posted
    Hello Thomas,

     

    Thank you for posting to Infragistics Community.

     

    I have been looking into your question and since there is no .NET type that holds hex numbers, my suggestion is to make this field a string type and bind it to a corresponding string property in your ViewModel, that will represent the UInt32 number. If your data source model requires that the field is UInt32, you could perform the needed type conversions before persisting the values.

     

    Below you will find attached a small sample I created to illustrate how string values, representing numbers can be switched between decimal and hexadecimal format with the help of some string formatting. Additionally, in case the field needs to be validated against the UInt32 range of values, the XamDataGrid’s EditModeEnding event is handled, so that the edited value is parsed to an UInt32 and the changes are not accepted in case the parse is not successful.

     

    Please, test the sample on your side and let me know if I may be of any further assistance.

     

    Sincerely,
    Bozhidara Pachilova
    Associate Software Developer