Reload Form1 when Form2 ShowDialog like?
-
Hi all! I asked for the issue as follows: I can program in C Windows Form. I have two Form: Form1 and Form2. Form1 has a datagrid and a button1. In the DataGrid displays the user with 2 column username and password. Form2 has two TextBox is txtTenDangNhap and txtMatKhau, and a Button btnLuu. In Form1: When Form1 loads the program will load a list of accounts available in the database to the DataGrid. When you click Button1, then Form2 will appear in the form of ShowDialog. (Form2 f2 = new Form2 (); f2. ShowDialog ()) (Note: Form1 is still not closed) On Form2: When pressing Button btnLuu, the new account will be saved to the database and Form2 will close. When Form2 is closed on Form1 DataGrid will load the data with the new account added. For help yourself with!
-
Hi all! I asked for the issue as follows: I can program in C Windows Form. I have two Form: Form1 and Form2. Form1 has a datagrid and a button1. In the DataGrid displays the user with 2 column username and password. Form2 has two TextBox is txtTenDangNhap and txtMatKhau, and a Button btnLuu. In Form1: When Form1 loads the program will load a list of accounts available in the database to the DataGrid. When you click Button1, then Form2 will appear in the form of ShowDialog. (Form2 f2 = new Form2 (); f2. ShowDialog ()) (Note: Form1 is still not closed) On Form2: When pressing Button btnLuu, the new account will be saved to the database and Form2 will close. When Form2 is closed on Form1 DataGrid will load the data with the new account added. For help yourself with!
Do you have a specific question you need help with? /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Do you have a specific question you need help with? /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
I have done, but also want to address up on this issue and for all, who needs it to use: In Form1: Set the button code below in the form1
Form2 f = new Form2();
if (f.ShowDialog() == DialogResult.OK)
{} else { //Load the list that you want }
In form2: Set the button code below in the form 2
this.DialogResult = DialogResult.Cancel;
-
I have done, but also want to address up on this issue and for all, who needs it to use: In Form1: Set the button code below in the form1
Form2 f = new Form2();
if (f.ShowDialog() == DialogResult.OK)
{} else { //Load the list that you want }
In form2: Set the button code below in the form 2
this.DialogResult = DialogResult.Cancel;
If a dialog wants the caller Form to perform some action, then it normally sets DialogResult to one of the predefined values (but not None nor Cancel), and the caller tests for that value. Using Cancel and putting the action in the else part of the test is extremely weird. Were you sober when you wrote this? :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
I have done, but also want to address up on this issue and for all, who needs it to use: In Form1: Set the button code below in the form1
Form2 f = new Form2();
if (f.ShowDialog() == DialogResult.OK)
{} else { //Load the list that you want }
In form2: Set the button code below in the form 2
this.DialogResult = DialogResult.Cancel;
The "proper" way to do this is to provide two buttons in Form2, and set their properties appropriately. The "OK" button has the DialogResult set to Dialogresult.OK The "Cancel" button has the DialogResult set to Dialogresult.Cancel The Form has its AcceptButton property set to the OK button, and is CancelButton set to the Cancel Button. The framework will then handle the buttons without any event handlers being necessary. These properties can be set at design time. In fact, I use a OK/Cancel button so often, I have made a VS Template to create it automatically - there is a Tip here which describes how to do it: Create Visual Studio forms for items you frequently use[^]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water