I am having a group box of width 900px and height 250px. and have to place 20 around radio buttons in it in a 4 rows * 5 columns tabular format. But at present its coming in 20 rows * 1 column format. And i have to do this using groupbox. I'll be glad for the answers thank you .

有帮助吗?

解决方案

Unfortunately, this is not imporssible, as Group control does not support overflow style child management. You have two options (maybe more):

  1. Create your custom group box and implement the "row overflow" logic yourself;
  2. You might embed a child TableLayoutPanel or ListBox in your group box, and add child items there;

for the TableLayoutPanel option, you might try below snippet to see if it matches your requriment:

TableLayoutPanel Table = new TableLayoutPanel();
Table.AutoSize = true;
Table.RowCount = 4;
Table.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
Table.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.AddCols;
this.Controls.Add(Table);

for the listbox, you can try this RadioListBox, and also set:

 listBox1.MultiColumn = true;

And also you need adjust the listbox height so that exactly 4 rows are there.

If WPF is an option, this will be trivial as you can do this with XAML, and implementation your own ItemTemplate is just a breeze.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top