2016-10-14 99 views
1

我想在messageBox上显示一个带comboBox显示的messageBox并返回组合框的结果。但我不知道如何添加一个组合框inisde the messageBox。我使用的是Visual Studio,编程语言是vb.net。任何人都可以帮忙
我想要的messageBox是MessageBox.Show(),而不是MsgBox()。
Thx为您的帮助~~MessageBox里面有一个comboBox并返回组合框的值

+0

'MsgBox'只是'MessageBox'的VB包装器。要添加组合,您需要编写自己的对话框或者使用“TaskDialog”。 – Plutonix

+0

MessageBox.Show和MsgBox是一回事。 – LarsTech

+0

@Plutonix如何编写自己的对话框? –

回答

1

使用自定义窗体而不是.ShowDialog()方法。你可能不得不重写DialogResult枚举,但我认为只要传回任何你需要的可能会更简单。

更新: 如果组合框提供了整数值,如果您在自定义窗体中将DialogResult设置为该整数,则可以这样做。 FYI ShowMsg是我的重载函数,它将根据发送的参数显示我的自定义窗体。

Dim Result As DialogResult = _ 
    ShowMsg("Select from the combobox", "Select an integer", ShowMsgButtons.OK, ShowMsgImage.Exclmation, ShowMsgDefaultButton.Button1) 
Select Case Result 
    Case 10 
     'what happens when they select 10 from the combobox 
    Case 20 
     'what happens when they select 20 from the combobox 
    Case 30 
     'what happens when they select 30 from the combobox 
End Select 
+0

所以我需要使用窗体并添加一些按钮与不同的DialogResult?例如btnOk - DialogResult = OK,btnCancel - DialogResult = Cancel。然后我用'If frmComboBox.DialogResult = DialogResult.OK ' –

+0

调用窗体,但是我如何返回Form I的组合框的值呢? –

+2

@JayChuah将其作为属性公开 – Plutonix

相关问题