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

program for addition of fraction(M/N + P/Q = Y/Z)

1 Answers   Mind Tree,


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

1 Answers   Satyam,


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

0 Answers  


Write a program to input an integer and - display the reverse - display the sum of each digit - should include logic that considers the input number as any number of digits long

2 Answers   Mind Tree,


"c sharp" code for factorial using static variables

9 Answers  






Using C# Write a program that performs the following. The user inputs a number and then enters a series of numbers from 1 to that number. Your program should determine which number (or numbers) is missing or duplicated in the series, if any. For example, if the user entered 5 as the initial number and then entered the following sequences, the results should be as shown. Input Sequence Output ---------------------- --------------- 1 2 3 4 5 Nothing bad However, if 7 were the high number, the user would see the results on the right for the following number entries: Input Sequence Output ---------------------- --------------- 1 3 2 4 5 Missing 6 Missing 7 And if 10 were the high number and the user entered the numbers shown on the left, note the list of missing and duplicate numbers: Input Sequence Output ---------------------- --------------- 1 2 4 7 4 4 5 10 8 2 6 Duplicate 2 ( 2 times) Missing 3 Duplicate 4 ( 3 times ) Missing 9 The program should check the high number that the user inputs to ensure that it does not exceed the size of any array you might be using for storage.

0 Answers  


how does the below eqation proceed to be solved: x*=y+z options: x=x*y+z or x=x*(y+z)

1 Answers  


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  


program to reverse the order of words in a string.

2 Answers   Mind Tree,


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

1 Answers   Mind Tree, SoftSol,


Write a program to count 3Letter, 4Letter and 5Letter words from a file and print the number of 3Letter, 4Letter and 5Letter words. Delimiter is space, tab, hifen. Also we should not consider the line in the file after we encounter # in that line.

0 Answers   Mind Tree,


Write a program to convert postfix expression to infix expression.

0 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)