In the following example, when the user hovers the mouse over the button, the form expands in y direction. When the user clicks on the button, the text on the button changes.
int size1 = 400;
int adder = 50;
public Form1()
{
InitializeComponent();
this.button1.Text = " Change Item ";
this.button1.Dock = DockStyle.Bottom;
this.button1.Click +=button1_Click;
this.button1.MouseHover += button1_Click_F2;
this.Controls.Add(this.button1);
this.dataGridView1.Dock = DockStyle.Top;
this.Controls.Add(dataGridView1);
this.Size = new Size(400, 200);
}
private void button1_Click(object sender, EventArgs e)
{
this.button1.Text = " Button1 Click is called ";
}
private void button1_Click_F2(object sender, EventArgs e)
{
this.Size = new Size(400, size1);
size1 = size1 + adder;
}
0 comments:
Post a Comment