Reputation:
Novice here, wanted to try to resize text in a label with a simple mouse over, but everything I seem to be trying isn't exactly working. Am I forgetting a property in the label? or is it the code?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void OnMouseEnter(object sender, EventArgs e)
{
label1.Font = new Font(label1.Font.Name, 20, FontStyle.Regular);
}
private void OnMouseLeave(object sender, EventArgs e)
{
label1.Font = new Font(label1.Font.Name, 9, FontStyle.Regular);
}
private void label1_Click(object sender, EventArgs e)
{
}
}
Upvotes: 0
Views: 2478
Reputation: 867
when you change ui properties make sure to call Refresh() or Invalidate() method of that control
Upvotes: 0
Reputation: 30042
You just forgot to attach your events didn't you:
public Form1()
{
InitializeComponent();
label1.MouseEnter += OnMouseEnter;
label1.MouseLeave += OnMouseLeave;
}
Or you can just do that through the designer.
Upvotes: 1