0

How to prevent form from auto loading when running the application?

i have a data grid view in a form,its data source code is in form load event which depends on variables in the main form, but when i enter the variables in the main form it goes wrong because the form was loaded when i run the application before i enter the variables so i need the form to load only when i use the code below i hope i expressed it clearly https://code.sololearn.com/cg0kBQspVvNW/?ref=app

21st Aug 2017, 5:52 PM
Abdul Aziz Al-Ayoubi
Abdul Aziz Al-Ayoubi - avatar
9 ответов
+ 2
Did you put this code in main form's form load event code? if you did then that's why formtable is loaded. If the formtable is already loaded simply set the form to foreground and set the grid filter with your input in main form. Please clarify what you mean by "it goes wrong"? Sorry if I misunderstood you.
21st Aug 2017, 6:20 PM
Ipang
+ 2
@Aziz, let's begin with fixing that code in formtable_load. on line 14: Replace case(universal.x) with switch(universal.x) Then we'll talk again, good luck.
21st Aug 2017, 7:00 PM
Ipang
+ 2
@Aziz, add another button and write the same code with button1_click, but change universal.x=0. Test if that works assigning dt1 for the grid. I'll be waiting.
21st Aug 2017, 7:27 PM
Ipang
+ 2
@Aziz let's verify the value of universal.x in formtable by adding a label control, and before switch(universal.x) add label1.Text=universal.x; I'm curious why this is happening.
21st Aug 2017, 7:33 PM
Ipang
+ 2
@Aziz, great, can I see the changes you made
21st Aug 2017, 7:45 PM
Ipang
+ 1
i found the mistake i swapped line 14 with line 15,16 in button1 code thank you for your patience
21st Aug 2017, 7:41 PM
Abdul Aziz Al-Ayoubi
Abdul Aziz Al-Ayoubi - avatar
0
it's my bad because i don't know where to start. i have 2 forms: main form and table form main form has button1 which load formtable https://code.sololearn.com/cg0kBQspVvNW/?ref=app universal is a class and x is public static with default value 0 formtable_load code is https://code.sololearn.com/ci83DNE8VyxO/?ref=app when i click on button1 i get dt1 instead of dt2 but when i click on it for second time i get dt1 I'm not sure what's wrong
21st Aug 2017, 6:41 PM
Abdul Aziz Al-Ayoubi
Abdul Aziz Al-Ayoubi - avatar
0
sorry about that, of course I didn't write that in the actual project :)
21st Aug 2017, 7:07 PM
Abdul Aziz Al-Ayoubi
Abdul Aziz Al-Ayoubi - avatar
0
i have already button2 with x=0, it works perfectly
21st Aug 2017, 7:28 PM
Abdul Aziz Al-Ayoubi
Abdul Aziz Al-Ayoubi - avatar