在Winform中自动调整表布局面板的工作?

时间:2013-05-15 05:45:49

标签: c# winforms tablelayoutpanel

我正在制作一个Windows应用程序,其中我使用的是表格布局面板,表格布局面板的结构是:

Total columns are : 1 -> Autosize
Total rows are : 6 -> Autosize

在后面的代码我添加4个单选按钮和单选按钮的文本有点长,我不想在一行中的文本,我想要像换行属性,添加单选按钮的代码是:< / p>

 for (int i = 0; i < 4; i++)
        {
            rbtn1 = new RadioButton();
            rbtn1.Name = "rbtn" + (i + 1);
            rbtn1.Text = "A jogger running at 9 kmph alongside a railway track in 280 metres ahead of the engine of a 120 metres long train running at 45 kmph in the same direction. In how much time will the train pass the jogger?";
            rbtn1.Dock = DockStyle.Fill;
            rbtn1.Font = new Font("Verdana", 10);
            tableLayoutQuestionAnswer.Controls.Add(rbtn1, 1, i+1);
        }

我的最终结果是:enter image description here

“火车”后的文字没有出现。这将是什么解决方案,我在过去2天尝试这个,需要帮助,非常感谢。

1 个答案:

答案 0 :(得分:0)

如果您将radiobutton的AutoSize值设置为false,并指定Width值,则会包装单词。

rdbButton.AutoSize = false;
rdbButton.Width = 100;