开发者

Delphi How to use TGridPanel

开发者 https://www.devze.com 2023-01-18 14:04 出处:网络
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开发者_如何学JAVA 4 columns which should have each 25% percent of

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开发者_如何学JAVA 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!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号