Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java->Listeners; c#->?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello all,
I just want to create controls through code and write click_event for them. In java, we can use listeners classes to do that. But I could not find any method in C#. Could any experts help me please?.

Thanks in advance,
leslie
 
Start a new Windows Forms project. Drag a button onto the form. Double-click on it. You will be taken to the click event code for that button in the code editor.

Unlike Swing/Java, in the .NET framework the form itself is a class.

Chip H.
 
However, if I am reading your post correctly, you want to code your code events without the use of the .NET IDE. I know of several developers that are doing this to avoid the hefty price tag on .NET. Notepad works just as fine.

Here's the event code that you seek...

private void button1_Click(object sender, System.EventArgs e)
{
//Event handling code here
}

Make sure that in your Initialize code for the form, that you set the event handler for the control. Here's an example...

this.button1.Click += new System.EventHandler(this.button1_Click);
Neil Konitzer
Freisoft
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top