Click here to Skip to main content
15,896,730 members
Home / Discussions / C#
   

C#

 
AnswerRe: Calling a method from another form Pin
m@u27-Nov-07 23:05
m@u27-Nov-07 23:05 
GeneralRe: Calling a method from another form Pin
N a v a n e e t h27-Nov-07 23:50
N a v a n e e t h27-Nov-07 23:50 
QuestionRe: Calling a method from another form Pin
Deques27-Nov-07 23:51
Deques27-Nov-07 23:51 
AnswerRe: Calling a method from another form Pin
m@u28-Nov-07 0:08
m@u28-Nov-07 0:08 
AnswerRe: Calling a method from another form Pin
N a v a n e e t h27-Nov-07 23:48
N a v a n e e t h27-Nov-07 23:48 
QuestionRe: Calling a method from another form Pin
Deques27-Nov-07 23:54
Deques27-Nov-07 23:54 
AnswerRe: Calling a method from another form Pin
Anthony Mushrow28-Nov-07 0:02
professionalAnthony Mushrow28-Nov-07 0:02 
AnswerRe: Calling a method from another form Pin
N a v a n e e t h28-Nov-07 0:08
N a v a n e e t h28-Nov-07 0:08 
Deques wrote:
I am not familiar with delegates


Delegates are function pointers in which you can assign a function's reference, and when delegate is invoked, supplied function will be called.

For explaining this we have two forms say Form1 and Form2. I am invoking Form2 from Form1's load event. Inside Form2 I have declared a delegate. See the Form2 code below
public class Form2 : System.Windows.Forms.Form
{
	public delegate void FormClosed();
	public FormClosed FormClosedHandler;

	private void Form2_Closed(object sender, System.EventArgs e)
	{
		FormClosedHandler();	//Invoking delegate
	}
}
In the above code, you can see I have created a FormClosed() delegate and an object for that delegate. This object I will be assigning from the Form1 just before Form2 is shown. See the Form1 code below
public class Form1 : System.Windows.Forms.Form
{
	private void Form1_Load(object sender, System.EventArgs e)
	{
		Form2 obj = new Form2();
		obj.FormClosedHandler += new Form2.FormClosed(this.Form2ClosedHandler);
		obj.Show();
	}
}
In this I have assigned a private method Form2ClosedHandler to the delegate. So when delegate is invoked, this private method in Form1 will get called. You can refresh your combo inside this method.

Delegates are good for communicating between classes.

Hope this helps

All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia

My Website | Ask smart questions

QuestionRe: Calling a method from another form Pin
Deques28-Nov-07 1:38
Deques28-Nov-07 1:38 
AnswerRe: Calling a method from another form Pin
N a v a n e e t h28-Nov-07 1:47
N a v a n e e t h28-Nov-07 1:47 
GeneralRe: Calling a method from another form Pin
Deques28-Nov-07 1:58
Deques28-Nov-07 1:58 
GeneralRe: Calling a method from another form Pin
N a v a n e e t h28-Nov-07 2:04
N a v a n e e t h28-Nov-07 2:04 
AnswerRe: Calling a method from another form Pin
Nouman Bhatti28-Nov-07 0:56
Nouman Bhatti28-Nov-07 0:56 
Questionhow to make const an input variable Pin
manustone27-Nov-07 22:30
manustone27-Nov-07 22:30 
AnswerRe: how to make const an input variable Pin
m@u27-Nov-07 22:41
m@u27-Nov-07 22:41 
GeneralRe: how to make const an input variable Pin
Colin Angus Mackay27-Nov-07 23:36
Colin Angus Mackay27-Nov-07 23:36 
AnswerRe: how to make const an input variable Pin
subai27-Nov-07 22:47
subai27-Nov-07 22:47 
GeneralRe: how to make const an input variable Pin
Colin Angus Mackay27-Nov-07 23:42
Colin Angus Mackay27-Nov-07 23:42 
GeneralRe: how to make const an input variable Pin
subai28-Nov-07 0:07
subai28-Nov-07 0:07 
QuestionListing the Domain in the the PDC Pin
M. J. Jaya Chitra27-Nov-07 22:24
M. J. Jaya Chitra27-Nov-07 22:24 
QuestionMedia RSS2.0 Parser Pin
rajshri_newase27-Nov-07 22:17
rajshri_newase27-Nov-07 22:17 
AnswerRe: Media RSS2.0 Parser Pin
Prateek G27-Nov-07 22:40
Prateek G27-Nov-07 22:40 
QuestionAdding items to List Pin
ramyanaidu27-Nov-07 22:15
ramyanaidu27-Nov-07 22:15 
AnswerRe: Adding items to List Pin
Nouman Bhatti28-Nov-07 1:01
Nouman Bhatti28-Nov-07 1:01 
Questioni need smallest hash string Pin
subai27-Nov-07 21:36
subai27-Nov-07 21:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.