我在winforms,C#應用程序中有一個ListBox。 我需要添加到代碼中的列表框CheckBoxes,我需要HorizontalScrollbar會出現時,有很多CheckBoxes和列表框不能顯示全部。 我已將列表框放在窗口上,並將它的HorizontalScrollbar設置爲true。我也設置了ListBox.But的最大高度和寬度,當我運行應用程序,我看不到所有的複選框... 任何人都可以幫助嗎?ListBox HorizontalScrollbar不能工作WinForms
這個添加的複選框代碼:
listBox1.HorizontalScrollbar = true;
this.groupBox_ChooseTCPipConfg.Controls.Add(listBox1);
CheckBox chk1 = new CheckBox();
chk1.Text = "chk1";
chk1.Location = new Point(2, 2);
listBox1.Controls.Add(chk1);
CheckBox chk2 = new CheckBox();
chk2.Text = "chk2";
chk2.Location = new Point(2,22);
listBox1.Controls.Add(chk2);
CheckBox chk3 = new CheckBox();
chk3.Text = "chk3";
chk3.Location = new Point(2, 42);
listBox1.Controls.Add(chk3);
CheckBox chk4 = new CheckBox();
chk4.Text = "chk4";
chk4.Location = new Point(2, 62);
listBox1.Controls.Add(chk4);
CheckBox chk5 = new CheckBox();
chk5.Text = "chk5";
chk5.Location = new Point(2, 82);
listBox1.Controls.Add(chk5);
CheckBox chk6 = new CheckBox();
chk6.Text = "chk6";
chk6.Location = new Point(2, 102);
listBox1.Controls.Add(chk1);
CheckBox chk7 = new CheckBox();
chk7.Text = "chk7";
chk7.Location = new Point(2, 122);
listBox1.Controls.Add(chk7);
CheckBox chk8 = new CheckBox();
chk8.Text = "chk8";
chk8.Location = new Point(2, 142);
listBox1.Controls.Add(chk8);
CheckBox chk9 = new CheckBox();
chk9.Text = "chk9";
chk9.Location = new Point(2, 162);
listBox1.Controls.Add(chk9);
CheckBox chk10 = new CheckBox();
chk10.Text = "chk10";
chk10.Location = new Point(2,202);
listBox1.Controls.Add(chk10);
當我運行的應用程序,我只能看到第7個複選框....
感謝下進行!成功了! –