I want to display &&
in the text of a button in a Windows Form application, but the displayed button displays only the text &
, with a single character.
// 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;
When I make a MessageBox, which tells what text is contained in the button.Text, it displays &&
(the desired result). However, the button found on the Windows Form contains only one character: &
.
Some of the methods I have already tried are shown below:
// 1
si.Text = "&" + "&";
// 2
char c = (char)38;
si.Text = c.ToString() + c.ToString();
// 3
si.Text = "&" + (char)38;
I have already tried to make the size of the button bigger, but it still did not work, the font is not the problem, in this case, as, for sure, the text fits the button size. I think it is worth to mention I have tried to give the text of the button values like &x
(si.Text = "&x")
and the only character to be found in the text of the button was x
.