views:

191

answers:

2

Hello,

I want to use Delphi's 2009 TGridPanel, but I don't understand how to use it correctly.

For example, I want to have a GridPanel with 4 columns which should have each 25% percent of the GripPanels width.

So I put a GripPanel on the form and add 4 ColumnItems. I give the column items SizeStyle ssPercent, and now I try to give each ColummItem a Value of 25 (ober the object inspector). But for some reasons the object inspector doesn't accept the value 25. It's automatically changed to something like '23,8095238095238'. Could somebody explain me in short how to use this components? Thanks!

+4  A: 

When you set the Value of a column with SizeStyle ssPercent, the component distributes the new sum of all ssPercent styled columns for the available total percentage. For instance, if you've got 4 25% columns and you set one to be 50% now you've got a total of 125%. The component calculates 'Value's again to have the total distributed proportionally, i.e. 50% -> 40% (100*50/125) .

To set the value of more than one columns at once, at run time you'd surround your code with GridPanel.ColumnCollection.BeginUpdate and GridPanel.ColumnCollection.EndUpdate.

And at design time edit the .dfm directly. Press 'Alt+F12' when you're viewing your form in the design editor, find your GridPanel in the text editor, edit the value of the columns there, and then press 'Alt+F12' again to return to the design view.

Sertac Akyuz
Thanks, that works! On note: After dropping a GridPanel on the form and deleting the rows and colums at designtime, these rows and columns still exist on runtime and you have to delete them manually. Little bit strange.
flinkiy1
+3  A: 

If you want to set all columns to the same value, select all columns in the structure view and then (assuming SizeStyle is already set to ssPercent) set the Value to 0. This will trigger some automatism that makes all of the colmuns sized equal.

Uwe Raabe