我想显示&&Windows窗体应用程序中按钮的文本&,但是显示的按钮仅显示具有单个字符的文本。
// this is how the button is declared and formatted
Button si = new Button();
si.Width = 25;
si.Height = 25;
this.Controls.Add(si);
si.bringToFront();
si.Text = "&&";
si.Font = new Font("Arial", 4, FontStyle.Regular) // as you can see, I made the font so small, in order to make sure the text fits the size of the button
si.Top = 10;
si.Left = 10;
Run Code Online (Sandbox Code Playgroud)
当我创建一个MessageBox时,它告诉button.Text中包含什么文本,它将显示&&(所需结果)。但是,在Windows窗体上找到的按钮仅包含一个字符:&。
我已经尝试过的一些方法如下所示:
// 1
si.Text = "&" + "&"; …Run Code Online (Sandbox Code Playgroud)