How it work when form1.enabled =false; form2.show() while form2 open.when form2 is close form1 will be enable.
Printable View
How it work when form1.enabled =false; form2.show() while form2 open.when form2 is close form1 will be enable.
don't use .show .... use .ShowDialog instead.
-tg
how about when i hide the form how can i return it to show?
Yes.
indeed. ShowDialog is best practice in terms of design but also user experience. you should never hide one form and show another. whilst its possible to do this, and can provide code, it is highly not recommended to do this.
furthermore, say for example your application is expecting some response from somewhere but form1 or form2 is hidden - how do you expect the application to exit or even display the form because of a coding bug that was undiscovered?
can give me example that focus on second form? not using ShowDialog on form2. i just use function of focus(). for form2.
it is highly advisable not to do what you are doing.
Modify the constructor of Form2 to take in Form1 instance and store it in a global private variable.
then in Form1 when you are doing to show form2, do this:Code:private Form1 mainForm;
public Form2(Form1 parentForm)
{
InitializeComponent();
this.mainForm = parentForm;
}
Code:
..
..
Form2 secondForm = new Form2(this);
secondForm.Show();
this.Hide();
then in form2 when you want to go back to the previous form, do this:
Code:this.Hide();
this.mainForm.Show();
new problem i run the same time of the form try my upload. i can't use topmost because of when alt+tab.
why code i will use.
sorry i dont understand. does this new problem have any relevance to the code given? if so and you are wanting to switch forms - you wont be able to because you are hiding a form and showing another form which is one of many reasons why you shouldnt be doing it this way :)
can be use focus? insted of showdialog?
why do you want to do that?
if a form is hidden, you cannot view it unless you call the Show() method on that form instance.
what are you trying to do? why can you not use ShowDialog? why are you avoiding to use this correct method?
please explain in detail what you are trying to achieve and why.
no i just run 2 form in the same time example my form1 is already show then i add on form1_load
form2 _form2 = form2();
_from2.show();
the form2 always at the back of the form1
solid,
I think you need to take a step back here.
Write down the exact requirements of what you are trying to do, i.e. what forms are visible and which ones aren't and at which point. What causes these things to happen? How you want the user to interact with the forms? etc.
Once we have all of the requirements, then the best overall recommendation can be provided.
I would also suggest that you look at some of the existing applications that you use already on your computer, i.e. Word, Visual Studio. Do these applications do the type of things that you are asking for? If not, then you might want to think about why you want to go against the grain. These applications will have invested hundreds of thousands of pounds/dollars trying to get the UI to be the best that they are, and you have to think they are doing things that way for a reason.
Gary
i made from vb.net example. not using Showdialog() and topmost
how to convert to C#?
post the code
There are a number of online converters that will be able to help you convert your VB.Net Code to C#. For instance:
http://www.developerfusion.com/tools.../vb-to-csharp/
Gary