标签图纸未以表格形式显示

时间:2016-08-09 08:04:01

标签: c# winforms

我想在同一个组框中添加2个标签,这是我的代码:

thick-green-border

但是当我启动该计划时, int x = 0; foreach (var item in comboboxinterface.Items) { drv = item as DataRowView; Button btn = new Button(); Label lblerrortoday = new Label(); Label lblcounterror = new Label(); btn.Text = drv.Row.ItemArray[0].ToString(); btn.Location = new System.Drawing.Point(10, 20 + (x * 30)); lblcounterror.Location = new System.Drawing.Point(100, 25 + (x * 30)); lblcounterror.Text = "No"; lblerrortoday.Location = new System.Drawing.Point(120, 25 + (x * 30)); lblerrortoday.Text = "Error Today"; grouptodayerror.Controls.Add(btn); grouptodayerror.Controls.Add(lblcounterror); grouptodayerror.Controls.Add(lblerrortoday); x++; } 没有显示,但lblerrortoday没问题,当我试图评论lblcountererror时,lblcounterror是显示很好,我错过了什么吗?

2 个答案:

答案 0 :(得分:1)

TextBox在那里,但与lblcounterror重叠。减少Width的{​​{1}},您会看到lblcounterror

答案 1 :(得分:1)

对我来说,你的方法似乎没问题,只指出可能导致不显示其他标签的标签宽度。

您可以使用 Control.AutoSize 属性,这可能会解决您的问题

lblcounterror.AutoSize = true;
lblerrortoday.AutoSize = true;