"How can I call a function from another form"
-
Dear every one, I am new in C# and I have a question about call function between two windows forms. In my project I have two windows form (form example Form1 and Form2) Form1 has some functions for itself(for example Func1,Func2,..) and Form2 has another functions (for example TempFunc1,TempFunc2,..).I'd like to call Func1 via Form2,I mean when the program is running and the TempFunc1 from Form2 is doing I want to call Func1 from Form1,how can I do this? Please help me. Yours Sincerely. Orchid
-
Dear every one, I am new in C# and I have a question about call function between two windows forms. In my project I have two windows form (form example Form1 and Form2) Form1 has some functions for itself(for example Func1,Func2,..) and Form2 has another functions (for example TempFunc1,TempFunc2,..).I'd like to call Func1 via Form2,I mean when the program is running and the TempFunc1 from Form2 is doing I want to call Func1 from Form1,how can I do this? Please help me. Yours Sincerely. Orchid
The main way to do this is to create delegates, so that your forms can call functions within each other. If you want something more quick and dirty, pass an instance of each form to the other form, and make the methods public. We need a FAQ, and this needs to be the first item on it. In fact, I thought we had one ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Dear every one, I am new in C# and I have a question about call function between two windows forms. In my project I have two windows form (form example Form1 and Form2) Form1 has some functions for itself(for example Func1,Func2,..) and Form2 has another functions (for example TempFunc1,TempFunc2,..).I'd like to call Func1 via Form2,I mean when the program is running and the TempFunc1 from Form2 is doing I want to call Func1 from Form1,how can I do this? Please help me. Yours Sincerely. Orchid
you could use of this function such as using a function in a class . Create a new instanse of ur form class and then call your function
-
Dear every one, I am new in C# and I have a question about call function between two windows forms. In my project I have two windows form (form example Form1 and Form2) Form1 has some functions for itself(for example Func1,Func2,..) and Form2 has another functions (for example TempFunc1,TempFunc2,..).I'd like to call Func1 via Form2,I mean when the program is running and the TempFunc1 from Form2 is doing I want to call Func1 from Form1,how can I do this? Please help me. Yours Sincerely. Orchid
See this article: Passing values between Forms in .NET[^] It passes values through properties - but properties are just syntactic sugar over getter and setter methods, so it works just as well for calling regular methods.
Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog
-
The main way to do this is to create delegates, so that your forms can call functions within each other. If you want something more quick and dirty, pass an instance of each form to the other form, and make the methods public. We need a FAQ, and this needs to be the first item on it. In fact, I thought we had one ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
Christian Graus wrote:
We need a FAQ, and this needs to be the first item on it. In fact, I thought we had one ?
This has been a long....long...did I say long running feeling. Heath Stewart and I started one about 3 years ago. I don't think it ever came to fruition.
- Nick Parker Microsoft MVP - Visual C#
My Blog | My Articles