I'm trying to enable UseMnemonic on a button so that the amprasand (&) will show up for me. The works fine unless I set the buttons flatStyle to System (all other flatstyles are fine).
Labels work fine with the same flatStyle, this seems to be specific to buttons.
Does any one know why this happens or a way behind it?
At the moment the only thing I can think of is ignore the UseMnemonic and add and extra & if one is found.
Also something else weird is that sometimes the & gets replaced with an underscore (_) but I can't yet reproduce this at will...
Far from the most effective code but something I through together to test this:
public Form1()
{
InitializeComponent();
this.label1.Text = "hello & goodbye";
this.button1.Text = "1&2";
this.label3.Text = this.button1.UseMnemonic.ToString();
this.label4.Text = this.button1.FlatStyle.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
switch (count)
{
case 0:
case 1:
this.label1.UseMnemonic = this.button1.UseMnemonic = false;
this.label1.FlatStyle = this.button1.FlatStyle = FlatStyle.System;
count = 2;
break;
case 2:
this.label1.UseMnemonic = this.button1.UseMnemonic = false;
this.label1.FlatStyle = this.button1.FlatStyle = FlatStyle.Flat;
count = 3;
break;
case 3:
this.label1.UseMnemonic = this.button1.UseMnemonic = false;
this.label1.FlatStyle = this.button1.FlatStyle = FlatStyle.Popup;
count = 4;
break;
case 4:
this.label1.UseMnemonic = this.button1.UseMnemonic = false;
this.label1.FlatStyle = this.button1.FlatStyle = FlatStyle.Standard;
count = 5;
break;
case 5:
this.label1.UseMnemonic = this.button1.UseMnemonic = true;
this.label1.FlatStyle = this.button1.FlatStyle = FlatStyle.System;
count = 6;
break;
case 6:
this.label1.UseMnemonic = this.button1.UseMnemonic = true;
this.label1.FlatStyle = this.button1.FlatStyle = FlatStyle.Flat;
count = 7;
break;
case 7:
this.label1.UseMnemonic = this.button1.UseMnemonic = true;
this.label1.FlatStyle = this.button1.FlatStyle = FlatStyle.Popup;
count = 8;
break;
case 8:
this.label1.UseMnemonic = this.button1.UseMnemonic = true;
this.label1.FlatStyle = this.button1.FlatStyle = FlatStyle.Standard;
count = 1;
break;
}
this.label3.Text = this.button1.UseMnemonic.ToString();
this.label4.Text = this.button1.FlatStyle.ToString();