Event Handling in C# Triggering a Button



Event Handling in C# Triggering a Button..

Answer / guest

using System;
using System.Windows.Forms;
using System.Drawing;

public class Butevent:Form {
TextBox t1 = new TextBox();
Button b1 = new Button();
public Butevent() {
this.Text = "C# Program ";
t1.Location = new Point(20,30);
b1.Text = "Click here to activate";
b1.Location = new Point(20,55);
b1.Size = new Size(150,20);

// Invoking Method or EventHandler
b1.Click+=new EventHandler(OnClick);

this.Controls.Add(t1);
this.Controls.Add(b1);

// Invoking Method or EventHandler
this.Resize += new EventHandler(OnResize);
}

//Applying EventHandler
public void OnResize(object sender,EventArgs ee) {
MessageBox.Show("oops! Form Resized");
}

//Applying EventHandler
public void OnClick(object sender,EventArgs e) {
t1.Text = "Hello C#";
}

public static void Main() {
Application.Run(new Butevent());
}

}

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More C Sharp Code Interview Questions

working with arrays

1 Answers  


program to check if a number is "perfect number".

1 Answers   Mind Tree, SoftSol,


How to Create a Treeview Menu in ASP.NET with C#?

1 Answers  


Code for Reading and writing from a file in c#?

1 Answers  


Code for Working with Files under a Directory?

1 Answers  


. Write a program to print the following outputs using for loops $ $ $ $ $ $ $ $ $ $ $ $ $ $ $

3 Answers  


How to Create Files by Using the FileInfo Class?

1 Answers  


IS Array list is generic or non generic

1 Answers  


How to Link Different Data Sources Together?

0 Answers  


Write a program to convert postfix expression to infix expression.

0 Answers   Mind Tree,


Write a program. there are 1..n numbers placed in an array in random fashion with one integer missing. find the missing number.

1 Answers   Infosys, Mind Tree,


Coding for Manipulate XML File Data Using C#?

1 Answers  


Categories
  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)