![](/img/trans.png)
[英]How to access each field in a Winform TableLayoutPanel in C#
[英]Winform Set readonly for tablelayoutpanel C#
我有一個tablelayoutpanel,其中包含許多控件。 我想鎖定此tablelayoutpanel,但可以在字段中復制數據。 Tablelayoutpanel僅具有ENABLED屬性->我無法在其中復制數據。 請幫助我鎖定tablelayoutpanel,並可以在這些字段中進行復制。
TableLayoutPanel
沒有允許該功能的內容。
而是循環遍歷所有控件,查看類型,然后設置所需的屬性:
foreach (var control in tableLayoutPanel1.Controls.Cast<Control>())
{
var tb = control as TextBoxBase;
if (tb != null)
tb.ReadOnly = true; // controls like TextBox and RichTextBox
else
control.Enabled = false; // all other controls
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.