• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Can I Close The Current Form and Open in it again

Can I close the Form , the Open it again automatically
0
Ahmadal_najjar2003
Asked:
Ahmadal_najjar2003
  • 8
  • 3
  • 3
  • +3
4 Solutions
 
Jeff CertainCommented:
The form, or the whole application?
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
Hi Ahmadal_najjar2003,

If it's all aplication you can use Application.Restart() or is the form ?
0
 
Ahmadal_najjar2003Author Commented:
Just the Form which I'm Using .
BillMaster.VB
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Ahmadal_najjar2003Author Commented:
The Goal is , to refresh all text , Comboboxes ,, so on. As I loaded for first time.
0
 
Priest04Commented:
Why dont you create some Reset() procedure that will set all controls to default values?

Goran
0
 
Ahmadal_najjar2003Author Commented:
Thats Right , I always do that. But I wish to find another easy way. Otherwise I will use Old way.
0
 
cwickensCommented:
Try this:
<asp:Button Text="Reset Form" id="btnReset" runat="server" />


In your code behind page write this:

Private Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
Me.Server.Transfer("myPage.aspx")
End Sub
0
 
Ahmadal_najjar2003Author Commented:
Sorry , I'm working with WIndows Application
0
 
Priest04Commented:
There isnt any other way.

Goran
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Other than this:

    Dim bm As New BillMaster
    bm.Show()
    Me.Close()

There isn't any other way to do it...
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
Even if it's possibl,e is not nice to do it because it takes more time then a refresh (it as to dispose the form and load it) and  it's not nice to the user (that see the flash closing and openning).
0
 
Ahmadal_najjar2003Author Commented:
like this it works

Dim bm As New BillMaster
        Me.Close()
        bm.ShowDialog()

it seems as you open new bill , as manual do.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
What version VB you using?
0
 
Ahmadal_najjar2003Author Commented:
vb 2008
0
 
Priest04Commented:
If its a modal doalog, then yes, you could do it like that, altough It is not the best way,, since you dont know how many times would you refresh it. So you would need to do something like this


bool refresh = true;

while (refresh)
{
    BillMaster frm = new BillMaster();
    frm.ShowDialog();

    refresh = frm.ReloadForm;
}

Where ReloadForm is the public property of BillMaster, and which you would set to true/false, depending weather you want to reload form after you close it.


But showing form as modal is often not very proffesional, and leaves user with less possibilities, and you should think weather you should make it less professional, in order to make your coding easier.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
I assume ShowDialog() is to keep the application from closing?

If so, click on Project --> Properties, then change the "Shutdown Mode" dropdown to "When last form closes".

Then you can it like I showed before:

    Dim bm As New BillMaster
    bm.Show()
    Me.Close()

...and the application will NOT close on you.  =)
0
 
Ahmadal_najjar2003Author Commented:
Really I have 2 great solutions , each with its own case
 
First If my Form will be opend as showdialog , solution of Priest04 is the one
and if my form as show() , Idle_Mind is the one .

Thanks for all .
0
 
Ahmadal_najjar2003Author Commented:
I also want to thank jpaulino because he give me new info (Application.Restart())

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 8
  • 3
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now