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
2395
UltraGrid Custom column widths
posted

Hey Guys,

I'm wondering if there is a simple way within the UltraGrid framework to solve this specific issue: Let's say I have 3 columns and I want to  have the first column take 25% of the available width, the middle column take 50% of the available width and of course the last column have the remaining 25% width. I know it is possible to hard code the widths of the columns with this type of method:

ultraGrid1.DisplayLayout.Bands[0].Columns[0].Width = (int)((ultraGrid1.ActiveRowScrollRegion.Width) / 4.0);

 but I'm trying to avoid issues relating to integer division, and taking into account when the scrollbar is visible or not. Is there something that I'm missing to set these types of custom column widths?

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    I beleive you can do this using RowLayouts. What you would do is set the grid's AutoFitStyle so that the columns fit within the grid. Set UseRowLayouts on the Band to true to turn on RowLayout. 

    Then what you would do is use the RowLayoutColumnInfo on each column. You would set the PreferredSize on each column to the same width and set the WeightX on each one to some relative values like .25, .5, and .25 respectively. 

Children