我如何设置ID名称以在Windows窗体中使用文本框用户控件进行标签

问题描述 投票:0回答:1

Here is i crated label with textbox user control

Here i am using that usercontrol in Form1 in multiple times

我想在Windows窗体中多次使用带有文本框的标签。所以我的问题是如何为控件分配ID?

c# user-controls
1个回答
0
投票
您可以使用Panel控件:https://docs.microsoft.com/en-us/dotnet/framework/winforms/controls/panel-control-windows-forms

并执行以下操作:

while (/*Some condition*/ ) { var newCtrl = new LabelTextEdit(); panel1.Controls.Add(newCtrl); // Rest of the code }

© www.soinside.com 2019 - 2024. All rights reserved.