RE ::::::::::::::::User Events

  • Thread starter Thread starter Sneha
  • Start date Start date
S

Sneha

Can we u define the user events in C# ?

If so can u snd me few code snippets?

My requirement is i want to fire a event when an item in
the datagrid is changed checking its validations and the
same event must fire when i click the tab key in the
datagrid ? How can i make that ?

Also other event when i change from one row to the other(
like a rowchanged event that too with a datagrid)

Please send me some code snippets?
 
Yes, ofcourse you can!

public delegate void EventHandler(object sender, EventArgs e);
public class Button: Control
{
public event EventHandler Click;
}
public class LoginDialog: Form
{
Button OkButton;
Button CancelButton;
public LoginDialog() {
OkButton = new Button(...);
OkButton.Click += new EventHandler(OkButtonClick);
CancelButton = new Button(...);
CancelButton.Click += new EventHandler(CancelButtonClick);
}
void OkButtonClick(object sender, EventArgs e) {
// Handle OkButton.Click event
}
void CancelButtonClick(object sender, EventArgs e) {
// Handle CancelButton.Click event
}
}

Source (you can find a lot more info here):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html
/vclrfcsharpspec_10_7.asp


--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 
Back
Top