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
70
How to tell UltraWinGrid to display the contents of Byte Arrays
posted

Hoping someone has a simple solution for me here.  I have an UltraWinGrid and we are binding a data table to it.  One of the columns in the data table is of type System.Byte[].  So when we display the grid, every cell value shows the string System.Byte[].    Is there a simple and efficient way to have the grid display a string or hex representation of the byte data.  I was hoping it would be as simple as setting a property on the grid's column. 

One Idea I was toying with was to handle this in an event while the grid is loading as well as the edit events, but I am worried about performance as our data sources can have thousands of rows.   

Parents
  • 469350
    Offline posted

    Hi Tim,

    What exactly do you want to display?

    What the grid does is it calls the ToString method on the cell's Value. The default ToString implementation for any class simply returns the type name. So that's why you are seeing "System.Byte[]".

    There are a number of ways you can change the display. In a case like this, I would probably use a CreationFilter to change the Text on the UIElement which is displaying that text. If you have not used a CreationFilter before that could be a little complicated, though.

    Another, much simpler, option is to hide the column and add an unbound column to the grid in it's place. Then you just use the InitializeRow event to read the value of the Byte array and set the Value of the unbound column in the same row to whatever you want the user to see.

     

Reply Children