I'm new at C#. I want to add '#' to HALLO (in the textBox) each time when you hover your mouse over the button.
This is what i have:
public partial class Form1 : Form
{
string Q = "HALLO";
string hashtag = "#";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
tB1.Text = Q;
}
private void bT1_MouseHover(object sender, EventArgs e)
{
tB1.Text += hashtag;
if (Q.Length > 20)
{
tB1.Clear();
}
lBkarakters.Text = Convert.ToString(tB1.Text.Length);
}
}
}
It does add the '#', but HALLO is gone.
public partial class Form1 : Form
{
string Q = "HALLO";
string hashtag = "#";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
tB1.Text = Q;
}
private void bT1_MouseHover(object sender, EventArgs e)
{
tB1.Text += hashtag;
}
}
or
public partial class Form1 : Form
{
string Q = "HALLO";
string hashtag = "#";
public Form1()
{
InitializeComponent();
tB1.Text = Q;
}
private void bT1_MouseHover(object sender, EventArgs e)
{
tB1.Text += hashtag;
}
}
Make sure you're event is registered: