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
130
GridColumnCollection.Contains Failed to test GridColumn
posted

My UltraWinGrid (V 9.1) behaves weird: the first screen shot show that the grid has 5 columns

however the following code:

grid.DisplayLayout.BandsSerializer[0].Columns.Contains("Gas") failed!

as screen shot 2 why?

 

 

  • 469350
    Verified Answer
    Offline posted

    This code fails because you are passing in a string. The Columns collection does not contain any strings, it contains a UltraGridColumn objects.

    You should be using the Exists method to see if a column exists with the specified key.

  • 130
    posted

    Resolved with following code; but I still don't know why the previous one failed:

    foreach(var  col in grid.DisplayLayout.BandsSerializer[0].Columns)
    {
        if( col.Key.Equals("Gas"))
               col.Width = iPresetValue;

    }

  • 130
    posted

    I've read Mike's post, he suggested not to use BandsSerializer. But my case is to resume stored Grid display information (column width etc)