简体   繁体   English

TableLayoutPanel的控制列属性

[英]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: 扩展属性是:

  • ColumnSpan. ColumnSpan。 Runtime: GetColumnSpan() and SetColumnSpan() 运行时:GetColumnSpan()和SetColumnSpan()
  • RowSpan. 行跨度。 Runtime: GetRowSpan() and SetRowSpan() 运行时:GetRowSpan()和SetRowSpan()
  • Row. 行。 Runtime: GetRow() and SetRow() 运行时:GetRow()和SetRow()
  • Cell. 细胞。 Runtime: GetCellPosition() and SetCellPosition() 运行时:GetCellPosition()和SetCellPosition()
  • Column. 柱。 Runtime: GetColumn() and SetColumn() 运行时:GetColumn()和SetColumn()

Obviously TLP was highly optimized to be used from the designer. 显然,TLP经过高度优化,可供设计师使用。 It's kinda of a pain at runtime. 这有点像运行时的​​痛苦。

Go here . 这里

This properties are added by means of "extending properties", something that other controls like ToolTip uses. 此属性通过“扩展属性”添加,这是ToolTip等其他控件使用的属性。

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);

for more check this 更多检查这个

http://en.csharp-online.net/TableLayoutPanel http://en.csharp-online.net/TableLayoutPanel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM