【问题标题】:Windows Form Buttons in C#C# 中的 Windows 窗体按钮
【发布时间】:2010-06-25 20:18:10
【问题描述】:

我想在我的 C# windows 窗体上添加一个名为“Click Me”的按钮

看起来按钮文本只接受空格之前的单词而忽略其余单词。 有: this.button_ClickMe.Text = "点击我";

仅显示带有文本“单击”的按钮。

知道为什么吗?有解决办法吗??

  • 伊瓦尔

【问题讨论】:

    标签: winforms button


    【解决方案1】:

    我怀疑按钮太小了。把它变大,或者设置AutoSize = true(显然,把它放在一个有足够空间的容器里)。

    这是一个适合我的示例:

    using System;
    using System.Drawing;
    using System.Windows.Forms;
    
    public class Test
    {
        static void Main()
        {
            Form form = new Form {
                Controls = {
                    new Button { 
                        Text = "Click Me!", 
                        AutoSize = true,
                        Location = new Point(10, 30)
                    },
                }
            };
            Application.Run(form);
        }
    }
    

    (诚然,这个示例甚至适用于 AutoSize = false,所以我怀疑你在某处硬编码了大小......或者你的字体更大。对于较长的文本,它只适用于AutoSize = true 或手动指定的大小。)

    【讨论】:

      【解决方案2】:

      按钮太小。让它稍微大一点。您可以(但不应该)在按钮上使用尽可能多的文本,包括 HitchHiker's Guide to the Galaxy 的整个部分。 (正在测试是否有限制)

      【讨论】:

        【解决方案3】:

        检查按钮的宽度。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2013-06-05
          • 1970-01-01
          • 2012-08-08
          • 2010-09-16
          • 2020-09-21
          • 1970-01-01
          相关资源
          最近更新 更多