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.
Hi,
The error message indicates that GetCellValue for this particular column is returning a string and not a Byte array. So perhaps you are mistaken about the type of the data contained in your data source?
You need to find out why the data is being returned as a string.
Hi Mike ,
I'm trying to get an image in my ultragrid. I'm using the InitializeRow event technique to get this done.
I'm getting an InvalidCastException . 'Unable to cast object of type 'System.String' to type 'System.Byte[]'.
I've tried to get the value this way:
Byte[] ba = (Byte[])e.Row.GetCellValue(band.Columns["Image"]);
Image being the hidden column.
Any ideas of how I can get this to work?
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.