.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Handiling a button's event

Posted By:Abhisek Panda       Posted Date: October 26, 2009    Points: 10    Category: Windows Form Controls    URL: http://www.dotnetspark.com  
 

This is a windows form application using C# . It shows how to handle an event of a button. It uses events like mouse enter, mouse leave, Click, etc..

There is a form with a button and a label which shows the event we are dealing with.



using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;



namespace WindowsFormsApplication1

{

public partial class Events : Form

{

public Events()

{

InitializeComponent();

}



private void btnEvents_Click(object sender, EventArgs e)

{

lblEvents.Text = "Button is clicked";

}



private void btnEvents_Enter(object sender, EventArgs e)

{

lblEvents.Text = "Button is Active";

}



private void btnEvents_Leave(object sender, EventArgs e)

{

lblEvents.Text = "Button is Inactive";

}



private void btnEvents_MouseEnter(object sender, EventArgs e)

{

lblEvents.Text = "Mouse is on button";

}



private void btnEvents_MouseLeave(object sender, EventArgs e)

{

lblEvents.Text = "Mouse is on form";

}



private void Events_Resize(object sender, EventArgs e)

{

lblEvents.Text = "resizing the form";

}

}

}



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend