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

Coding for using Nullable Types in C#?

1 Answers  


write a Program to copy the string using switch case.

0 Answers   Mind Tree, Wipro,


How to pass multiple rows from one gridview to another gridview after clicking the checkbox.

1 Answers   Satyam,


Hello Sir, Thanks for the Solution but, can you pls. Explain the coding for the Static Function & static variable from the below coding....waiting for Ans. class fact { public static void Main() { fact f=new fact(); int x=1; //Declaration of x as 1 int k=Convert.ToInt32(Console.ReadLine()); for(int i=1;i<=k;i++) { x= x *i; } System.Console.WriteLine(x); } }

0 Answers  


Write a program to convert postfix expression to infix expression.

0 Answers   Mind Tree,






program for string reverse(eg:- i am boy -> boy am i)

8 Answers   Black Pepper, Infosys, Mind Tree,


Write a program to count the number of characters, number of words, number of line in file.

2 Answers   Mind Tree,


IS Array list is generic or non generic

1 Answers  


Write a program which has a function and that function should take 2 or 3 or any number of strings and it should return the largest common prefix of all those strings. If there is no common prefix it should return an empty string. for eg:- INPUT OUTPUT glo {glory,glorious,glod} gl {glad,glow} {calendar,phone} empty string

2 Answers   Mind Tree,


How to add a value from textBox over an existing certain column in SQL Server

0 Answers  


how do i copy textbox contents of 1 form to another form

4 Answers   Wipro,


program to reverse the order of words in a string.

2 Answers   Mind Tree,


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)