+ 1
how to call event after load
My english isn't very good. In Windows Forms we have Form_Load(...), how can I do it in my class?
16 Respuestas
+ 6
you can find sample in link below
https://code.sololearn.com/Wkl3IriRYcK1/?ref=app
+ 6
window.onload = function() {
// your code here
}
+ 1
Ok, but if we have... I don't know C#... Is constructor in Windows Forms and we can make Form_Load. How make this? It can be JS C# etc.
+ 1
Where do you start, what do you want to do ? What is your development environment?
if you start in visual atudio, and you have a winforms project. You can go to the project explorer, choose add and add a empty form. If you have the empty form you can go to the proporties window and add event from the events tab.
+ 1
Sorry
C#
VISUAL STUDIO 2017 community
I want to make an event in my class that will be working as event Load in Windows Forms
+ 1
Good answer
Is your class a class or a form ?
+ 1
This was a lot harder than expected.
I haven't solved the problem yet but I like to hear from you, what you already know about events.
Here is some code, I have written for you.
https://code.sololearn.com/c3Ua61bw096U
My simple thought was
1) make a delegate
public delegate void Reached5EventHandler();
2) create the event
public event Reached5EventHandler OnReached5;
3) write the code that fires the event
if( animalcount == 5 && OnReached5 != null)
{
OnReached5();//Raise the event
}
4) create a method that does something when the event fires
static private void DoReach5()
{
Console.WriteLine("This is the point where you can react on the event");
}
5) assign the event handler to a method in the main
myFarm.OnReached5 += new AnimalFarm.Reached5EventHandler(DoReach5);
This works for Reached5 event
but not for OnLoaded event
Why not because
The event is raised before it is assigned
I do not know you what your current knowledge is
Hope this helps ?
Did you already make a event like Reached5 ?
I Need to think further about how to created a real OnLoaded event
Some links I used
https://www.intertech.com/Blog/c-sharp-tutorial-understanding-c-events/
https://www.codeproject.com/Articles/11541/The-Simplest-C-Events-Example-Imaginable
+ 1
Your welcome, please ask your questions here in the Q&A (use tag c#)
+ 1
Ok :)
0
Are you looking for a constructor ?
myclass (){}
or a public method you can call
public method1 (){}
or a real event ?
0
Class a class
0
Do you want method when you create the object or just a method that you can call or a real event ?
0
event
public Window()
private void Window_Load(object sender, EventArgs e)
this Window_Load calling after Window() but I don't call anywhere Window_Load how make this event in my class
0
so?
0
Please wait a sec. The answer is in my head already. I did not have the time to write it down.
0
Thanks for your time and help, I'd like to know if its possible to continue our cooperation, and If you could support me with some advices next time. I will try doing my best. Thanks in advance.