Click here to Skip to main content
15,889,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a window form, when i click on add button a new form open again when i click on ok button of this form(secode form) new form open and click the save button of this form button a grid refresh of main form , the main grid refresh on save and also cancel button , but i want to only refresh grid on save button not on cancel using delegate , how can i do this please help me.
Posted
Comments
_Zorro_ 17-Feb-14 10:23am    
Why don't you just use two different events for the save and the cancel buttons on the main form?

Don't use delegates - use events: you have three forms:
main -> second ->third
When you press the button in the third form, it signals an event which is handled in the second form.
This event handler raises an event which is handled by the main form which then refreshes it's own grid.

This is very simple to arrange: A Simple Code Snippet to Add an Event[^] shows you how (as well as adding a snippet to Visual Studio to make it easier later)
And Transferring information between two forms, Part 2: Child to Parent[^] shows an example of using events to do something similar.
 
Share this answer
 
Yeah, you can use delegates.
In my opinion events are delegates too. See my code below, it is not relevant to your answer, but you will certainly have an idea how it works

C#
Form_Load(...)
{
    addBtn.Click += delegate
    {
        // do your operations
    };
}


Let me know, if anything is not clear to you :)

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900