Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi How to use TGridPanel

Tags:

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!

like image 626
flinkiy1 Avatar asked Oct 01 '10 09:10

flinkiy1


2 Answers

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 columns sized equal.

like image 108
Uwe Raabe Avatar answered Sep 18 '22 15:09

Uwe Raabe


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.

like image 33
Sertac Akyuz Avatar answered Sep 21 '22 15:09

Sertac Akyuz