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
565
Format cell bound to a datatable with a byte[] array
posted

Hi,

I have a bound data table which has a byte array column.

How can I format a specific cell that is bound to a byte array ?

I would like to display the hexadecimal value of the byte array.

Thanks.

  • 21795
    Offline posted

    Hello Abraham,

    As Mike wrote there are several ways to achieve this. Please find attached a sample solution implementing approach with DataFilter. The steps to implement this approach are:

        1.Add UltraTextEditor to your UltraGrid specific cell or column.

        2. Create a custom class implementing IEditorDataFilter interface. This interface allows you to "intercept" the values assigned to and from the editor and its owner, and change those values as required by the application.

        3. Set to UltraTextEditor’s DataFilter property to an instance of the custom class.

    More about IEditorDataFilter you can find by following next link http://help.infragistics.com/Help/Doc/WinForms/2012.1/CLR2.0/HTML/WinGrid_Using_the_IEditorDataFilter_Interface_with_WinGrid.html

    Please let me know if this is what you are looking for or if I am missing something.

    CAS-146109-P3Y7Q7.zip
  • 469350
    Offline posted

    Hi Kal,

    There's no simple way to convert or format a byte array into a hexadecimal number that I am aware of. But there are a number of approaches you can take.

    The simplest approach would be to hide the byte array column and add an unbound column to the grid. You would handle this in the InitializeLayout event of the grid.

    Then you would use the InitializeRow event to retrieve the byte array, convert it into a hexadecimal string and apply that string to the value of the unbound column.

    Another approach would be to use a DataFilter. Using a DataFilter allows you to do essentially the same thing without needing an extra column. The down side is that you have to convert both ways - from byte array to hexadecimal, but also from hexadecimal to byte array. If the byte array field needs to be editable, then you would have to do this, anyway, of course. So if the field is read-only, the unbound column approach is better. If it's editable, then the DataFilter approach is probably better.

    If the field is not editable, then there is another option, which is to simply override the drawing of the cell using a CreationFilter or DrawFilter and just draw the text yourself without affecting the value of any cell. This approach is a little more efficient than the unbound column approach, but it's a little more complex to implement, especially if you are not familiar with CreationFilters.