[英]TableLayoutPanel's Control Columns properties
I've noticed that every control added to the TableLayoutPanel is given "Column" and "Row" properties. 我注意到添加到TableLayoutPanel的每个控件都有“Column”和“Row”属性。 How can I get access to these properties through code?
如何通过代码访问这些属性?
thanks:) 谢谢:)
These properties only exist in the Properties Window, magic provided by the IExtenderProvider interface. 这些属性仅存在于IExtenderProvider接口提供的属性窗口中。 They don't exist at runtime.
它们在运行时不存在。 Extended properties are:
扩展属性是:
Obviously TLP was highly optimized to be used from the designer. 显然,TLP经过高度优化,可供设计师使用。 It's kinda of a pain at runtime.
这有点像运行时的痛苦。
Although the properties designer shows the row and column as properties of the added control thay are set programatically using a method on the table layout panel itself (SetColumn(control, index) and SetRow(control, index)). 虽然属性设计器将行和列显示为添加的控件的属性,但是使用表布局面板本身上的方法(SetColumn(control,index)和SetRow(control,index))以编程方式设置。
This pattern of behaviour is similar the tool tip component and the error component. 这种行为模式类似于工具提示组件和错误组件。
// Create TableLayoutPanel TableLayoutPanel tlp = new TableLayoutPanel(); //创建TableLayoutPanel TableLayoutPanel tlp = new TableLayoutPanel();
// Set the BorderStyle to Inset tlp.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset; //将BorderStyle设置为Inset tlp.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset;
// Grid has two columns
tlp.ColumnCount = 2;
// Grid has two rows
tlp.RowCount = 2;
// If grid is full add extra cells by adding column
tlp.GrowStyle = TableLayoutPanelGrowStyle.AddColumns;
// Padding (pixels)within each cell (left, top, right, bottom)
tlp.Padding = new Padding(1, 1, 4, 5);
// Add TableLayoutPanel to the Forms controls
this.Controls.Add(tlp);
http://en.csharp-online.net/TableLayoutPanel http://en.csharp-online.net/TableLayoutPanel
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.