.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 >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Creating your own event of user controls in windows application

Posted By:Nikhil Kumar       Posted Date: April 01, 2010    Points: 25    Category: .Net Framework    URL: http://www.dotnetspark.com  

Creating your own event of user controls in windows application. Here we are going to learn how to create our own event of usercontrol which we create in C# Windows Control Library and further use in windows Applications.
 

Creating your own event of user controls in windows application ):-{)

Hello friends! Here we are going to learn how to create our own event of usercontrol which we create in C# Windows Control Library and further use in windows Applications.

1- We know how to create UserControl for windows application.

Here are some remembering steps for creating UserControl

First choose New -> Projects -> C# -> Windows Control Library -> Then create your own control -> Build Application.

Now our usercontrol .dll has been generated .

Now when we use this usercontrol in our C# windows application and double click it for the programming.

Then this comes.

private void userControl11_Load(object sender, EventArgs e)

Now what we are going to do is. place our event name in place of Load

So what we have to do now for achieving this task.

use this program lines in your usercontrol___

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Usercontrolforevent
{
[DefaultEvent ("myClick")]
public partial class UserControl1 : UserControl
{
public delegate void myClickdel();
public event myClickdel myClick;

public UserControl1()
{
InitializeComponent();
}

private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString();

}
}
}


Now if you use this usercontrol in your windows application and click it for programming then a event will generate with the name myClick see how.

private void userControl11_myClick()
{

// Do what you want to do.

}

I hope you liked this article if you want any help simple drop me a line i will try to solve .

Thanks !!!! for being with me.ever .forever

¤Your's

Nikhil

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

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