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
540
Cell Format not appearing
posted

I am loading a dataset with a field set as string.  This field holds just the digits of a phone number.

I have a WinGrid on a form with the dataset assigned as the datasource.  Using UltraWinGrid Designer I set the "Phone" columns Format to (###) ###-####

However when the application is ran and the gird is loaded the "Phone" column still shows just the digits.  I then returned and set the "Phone" columns MaskInput value to (###) ###-####

When I run the application, again the column does not get formated, but if I click one of the Phone cells the format does show up.  I plan on making this grid not to allow, edits, additions or deletions so the user will never be selected edit mode on a cell. 

I just am puzzled as to why when I enter a format it is not formatting that column as expected.

Parents
  • 469350
    Verified Answer
    Offline posted

    When the grid cells displays the value, it calls ToString on the Value of the cell and passes in the Format you specified. The String data type does not accept any parameters to the ToString method and so strings to not support formatting.

    Once you enter edit mode on the cell, the format is no longer applied, but the Mask is used. 

    I think you might be able to get what you want by using the MaskDisplayMode.  But if that doesn't work, then you will need to use a numeric data type in order to format the data for display. 

    Alternately, you could use a DataFilter and manipulate the strings yourself in code. 

     

Reply Children