|
-
Jun 5th, 2010, 08:40 PM
#1
Thread Starter
Addicted Member
[RESOLVED] how to keep a modal form displayed under a messagebox?
Hi all.
I have a parent form, which can lanch a dialog box. A wrong selection in the box launches a message box with an error message. When the message box pops up, the dialog box disappears, so the messagebox is sitting on top of the parent form.
Once the user clicks "OK" in the messagebox, the box disappears, and only the parent form remains.
How do I make it so that the dialog box remains when the messagebox is displayed? And also, I want the dialog box to remain when the user closes the message box. The user should have the option to make the right selection in the dialogbox once the messagebox disappears.
I tried to hunt for a property for the dialog box to achieve this, but couldn't find any.
Here is the code in the parent form to lauch the dialog box, and to also launch the messagebox, when the user has made a selection in the dialogbox:
Code:
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
Dim selectedFile As DialogResult = frmOpenFileDialog.ShowDialog
If selectedFile = DialogResult.OK Then
Dim extension As String
' get index of "." in the filename
Dim index1 = frmOpenFileDialog.lstDisplayFiles.SelectedItem.indexof(".", 0)
' get the extension of the file
extension = frmOpenFileDialog.lstDisplayFiles.SelectedItem.substring(index1 + 1)
' open file
If extension = "txt" Or extension = "html" Then
rchtxtDisplay.LoadFile(frmOpenFileDialog.longPath & frmOpenFileDialog.lstDisplayFiles.SelectedItem, _
RichTextBoxStreamType.PlainText)
Else
MessageBox.Show("Can only open files ending in .txt or .html", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End If
End Sub
Am I having this problem because all the code to launch the dialog and message boxes reside in the parent form? If I put the code to launch the messagebox in the dialog box, would that make the dialog box persistent when the messagebox is launched? I am putting all the code in the parent form because it can process the DialogResult.
Thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|