I have a DataGridView with data loaded from a database. Each row has a 'View' button and when I click on it another form is opened with specific information but the main form with the DataGridView is still opened. I do this with this code:
FormView fr = new FormView(id);
fr.ShowDialog();
The problem is that I can't open several FormViews at the same time because the focus is still in the first FormView opened. How can I do this?
when you use ShowDialog on a form it shows and waits for a response of type DialogeResult, but when you just need to show a form and no response is needed you can simply call form.Show()
here is the code :
When you want a result:
Form f = new Form();
DialogResult res = f.ShowDialog();
//code stops here until you return something of type DialogResult
if (res == System.Windows.Forms.DialogResult.OK)
I_Will_Run_Just_When_DialogReult_Returned_Is_OK();
when you only want to show the form:
f.Show();
I_Will_Run_Anyway_Right_After_Showing_Form();
ShowDialog
opens a modal form which means that the ShowDialog
method won't return until the user has closed the form.
Use fr.Show
method instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With