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?
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.
Hi Mike,
Can you please post code example of this relevant to UltraWinGrid v 10.3?
Thanks.
It's really hard to make a sample demonstrating this, since it's all done at design-time. Setting up a RowLayout at run-time is very complex and difficult, so I strongly recommend using the grid designer to set it up the way you want visually.
How do I do that at design time if I'm using a dataset to load data at runtime?
You can set up your DataSet with the tables and columns you need at design-time.
Or, you could go into the grid designer and manually design a schema that matches what you will be binding to at run-time.
Either way, the schema has to exist at design-time in order to do this at design-time.
If you want to try to set up the layout at run-time, then you should read up on GridBagLayouts. You will need to set the RowLayoutStyle on the band and then set up the RowLayoutColumnInfo on each column in the grid. I'm pretty sure if you search for RowLayoutColumnInfo here on the forums, there is some sample code posted which might help you understand how it works.
But like I said, setting up a RowLayout in code is pretty complex, even if you have a lot of experience with GridBagLayouts. I recommend setting up your schema at design-time if you possibly can.