Vb.net 如何使主窗体等待我创建的自定义对话框的结果?
我正在尝试制作一个搜索功能,它有两个以上的开放式选项,在我为两个选项实现它之前,我想让它为其中一个工作,这是可以理解的 我决定做的是创建一个自定义对话框,并使用它来显示输入的搜索条件产生的列表 以下是调用该对话框的代码:Vb.net 如何使主窗体等待我创建的自定义对话框的结果?,vb.net,winforms,Vb.net,Winforms,我正在尝试制作一个搜索功能,它有两个以上的开放式选项,在我为两个选项实现它之前,我想让它为其中一个工作,这是可以理解的 我决定做的是创建一个自定义对话框,并使用它来显示输入的搜索条件产生的列表 以下是调用该对话框的代码: Sub search(ByVal sender As Object, ByVal e As EventArgs) Handles btnSearch.Click Dim temp As String Dim tempSplit As String() D
Sub search(ByVal sender As Object, ByVal e As EventArgs) Handles btnSearch.Click
Dim temp As String
Dim tempSplit As String()
Dim check As Boolean = False
'instance creation of dialog box
Dim extendSearch As New TypeClassSearch()
Select Case cmbSearch.Text
Case "Name"
'working and appropiate code
Exit Select
Case "Number"
'working and appropriate code
Exit Select
Case "Type"
check = True
'shows dialog
extendSearch.Show()
'doesn't wait for input from the dialog and just goes through the code before user can interact
If extendSearch.DialogResult() = System.Windows.Forms.DialogResult.OK Then
For i As Integer = 0 To pokemonList.Length - 1
If extendSearch.selection = pokemonList(i) Then
temp = weaknesses(i)
tempSplit = temp.Split(CChar("\"))
weaknesses(i) = ""
For k As Integer = 0 To tempSplit.Length - 1
If k <> tempSplit.Length - 1 Then
weaknesses(i) += tempSplit(k) + ", "
Else
weaknesses(i) += tempSplit(k)
End If
Next
temp = resist(i)
tempSplit = temp.Split(CChar("\"))
resist(i) = ""
For k As Integer = 0 To tempSplit.Length - 1
If k <> tempSplit.Length - 1 Then
resist(i) += tempSplit(k) + ", "
Else
resist(i) += tempSplit(k)
End If
Next
lblNum.Text = pokedexNum(i)
lblPkmn.Text = pokemonList(i)
lblType.Text = typings(i)
lblClass.Text = classifications(i)
lblWeak.Text = weaknesses(i)
lblResist.Text = resist(i)
lblPkdxX.Text = pokedexX(i)
lblPkdxY.Text = pokedexY(i)
End If
Next
End If
Exit Select
Case "Class"
'hold code, next extended criteria
Exit Select
End Select
If check = False Then
MessageBox.Show("Pokemon Not Found. Please check your spelling or try again.")
End If
End Sub
任何帮助都将不胜感激。=) 更改,
extendSearch.Show()
为extendSearch.ShowDialog()
哇,这是一个很容易解决的问题。。。不过,谢谢!当你的回答让我满意时,我会接受的。
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK
selection = CStr(chkSearch.SelectedItem)
Me.Close()
End Sub