By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,122 Members | 2,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,122 IT Pros & Developers. It's quick & easy.

about events

P: n/a
i registered two events with a button.
when i press it , how can i know which is fired first?
or is there a way to make one of them get fired before the other one?

in fact i made a experiment about it :

i put message boxes in the events, when i press button only one event is
fired and other is never. why does that happens?
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
hi,
based on this sample, events are fired according
to the sequence of subscription.

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

public class WindowsForm : System.Windows.Forms.Form
{
private Button btn = new Button();

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

public WindowsForm()
{
btn.Click += new EventHandler(btnClick1);
btn.Click += new EventHandler(btnClick3);

btn.Click += new EventHandler(btnClick2);
btn.Text = "Click";
this.Controls.Add(btn);
}

private void btnClick1(object sender, EventArgs e)
{
MessageBox.Show("1");
}

private void btnClick2(object sender, EventArgs e)
{
MessageBox.Show("2");
}

private void btnClick3(object sender, EventArgs e)
{
MessageBox.Show("3");
}

}
HTH,

--
gani
http://thedeveloperscorner.com.ph
-----Original Message-----
i registered two events with a button.
when i press it , how can i know which is fired first?
or is there a way to make one of them get fired before the other one?
in fact i made a experiment about it :

i put message boxes in the events, when i press button only one event isfired and other is never. why does that happens?
.

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.