'Why does my label not have any text in it? C# WinForms
I have the following subroutine to create a label, located in form 1:
private void MakeLabelForGameStyle()
{
Label SelectedMode = new Label();
SelectedMode.Text = form2obj.GameStyle;
SelectedMode.Location = new Point(507, 92);
SelectedMode.AutoSize = true;
SelectedMode.Font = new Font("Calibri", 12);
Controls.Add(SelectedMode);
}
In form 2, the relevant code to determine 'GameStyle' is as follows:
private string gameStyle;
private void button3_Click(object sender, EventArgs e)
{
gameStyle = "Best Of 3";
Close();
}
private void button4_Click(object sender, EventArgs e)
{
gameStyle = "Best of 5";
Close();
}
public string GameStyle
{
get { return gameStyle; }
}
But when I run the program, the label is blank after clicking either of the buttons.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
