Winform Forms Closing and opening a new form

后端 未结 8 1252
时光说笑
时光说笑 2020-12-06 07:47
1. frmHome frm = new frmHome();
   frm.Show();
   this.Close();

I\'m opening HomeForm from LoginForm. In LoginForm

8条回答
  •  孤街浪徒
    2020-12-06 08:03

    I'm not quite sure I'm understanding this, perhaps you could do something like this if you want to loop through a specific order of forms: (pseudo code)

    Dim formsList as New List(Of form)
    formsList.add(Form1)
    formsList.add(Form2)
    formsList.add(Form3)
    ' etc etc etc '
    
    For Each f as Form in formsList
    
        f.ShowDialog()
        ' you could have a condition here which breaks the for loop perhaps '
    
    Next
    
    Me.close ' close the app '
    

    You could add a condition into the For loop which breaks the for loop to end early...

    note: sorry for the vb.net code...but it should be easy to understand though

提交回复
热议问题