【发布时间】:2014-07-18 14:29:51
【问题描述】:
好的,我有这段代码可以在我的表单上创建控件:
public CableID_DuplicateView(CableID_CreateView CView)
{
InitializeComponent();
Label lbl = new Label();
Button btn = new Button();
ComboBox cmb = new ComboBox();
TextBox txt = new TextBox();
if (CView.input == 1)
{
lbl.Text = "Please select a cable number to duplicate:";
lbl.Location = new Point(12, 9);
cmb.Location = new Point((lbl.Width + 17), 6);
cmb.Size = new System.Drawing.Size(125, 20);
btn.Location = new Point((lbl.Width + cmb.Width + 17), 5);
btn.Size = new System.Drawing.Size(90, 23);
btn.Text = "Add to Table";
this.Height = cmb.Height + 48;
this.Width = lbl.Width + cmb.Width + btn.Width + 34;
this.Controls.Add(lbl);
this.Controls.Add(cmb);
this.Controls.Add(btn);
}
}
产生这个:
是什么导致我的标签被这样切断?为什么组合框坐在一个奇怪的位置?
【问题讨论】:
-
你需要设置宽度,可能会被拉到文本框后面
-
在标签上设置宽度
标签: c# winforms visual-studio controls