c# - 在 Winform 中自动调整表格布局面板不起作用?

标签 c# winforms tablelayoutpanel

<分区>

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

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

在后面的代码中,我添加了 4 个单选按钮,单选按钮的文本有点长,我不希望文本在一行中,我想要类似换行属性的东西,添加单选按钮的代码是:

 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

“train”之后的文本没有出现。这个问题的解决方案是什么,我从过去 2 天开始尝试这个,需要帮助,非常感谢。

最佳答案

如果将单选按钮的 AutoSize 值设置为 false,并指定 Width 值,则单词将被换行。

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

关于c# - 在 Winform 中自动调整表格布局面板不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16557721/

相关文章:

c# - DataGridView 的行为就好像它在 TableLayoutPanel 中具有最小尺寸一样

C# .NET TableLayoutPanel 的最后一列被拉伸(stretch)

c# - SQLite.CodeFirst - 创建模型时无法使用上下文

c# - ASP.net.MVC 5 创建一个显示 sql 查询的页面

c# - 使用 winforms 给 excel 单元格上色

c# - 在其他所有内容后面显示一个表单,而不窃取焦点?

c# - 为什么在 DataGridView 控件中删除行时出现此错误?

c# - ASP.NET Core 3.1 OData PageResult 序列化

c# - 如何使标签在 WinForms 中居中?

c# - tablelayoutpanel 内的 tablelayoutpanel 处置