|
-
Aug 15th, 2002, 04:30 PM
#1
Thread Starter
Member
Modify return value of ShowDialog method
The ShowDialog method of a WindowsForm returns a DialogResult Enum, but how do you modify the value that is returned?
Thanks. Lance
-
Aug 16th, 2002, 09:09 PM
#2
PowerPoster
I don't think you can change the enum that you can pass back, but you do have control as to what is passed back. I got this from the msdn library.
This code will make a button (an OK button on a form) make the dialog result be an OK result.
VB Code:
Private Sub InitializeMyButton()
' Create and initialize a Button.
Dim button1 As New Button()
' Set the button to return a value of OK when clicked.
button1.DialogResult = DialogResult.OK
' Add the button to the form.
Controls.Add(button1)
End Sub 'InitializeMyButton
Here is the enumeration members that are available:
The Button.DialogResult property and the Form.ShowDialog method use this enumeration.
Abort The dialog box return value is Abort (usually sent from a button labeled Abort).
Cancel The dialog box return value is Cancel (usually sent from a button labeled Cancel).
Ignore The dialog box return value is Ignore (usually sent from a button labeled Ignore).
No The dialog box return value is No (usually sent from a button labeled No).
None Nothing is returned from the dialog box. This means that the modal dialog continues running.
OK The dialog box return value is OK (usually sent from a button labeled OK).
Retry The dialog box return value is Retry (usually sent from a button labeled Retry).
Yes The dialog box return value is Yes (usually sent from a button labeled Yes).
-
Aug 19th, 2002, 09:24 AM
#3
Thread Starter
Member
Thanks. That is exactly what I was looking for.
Now I have another question though ... Is it possible to show a Form as Modal without using the ShowDialog method? For example, I would like to do the following:
Code:
'Prevent the existing ShowDialog method from being Called
Private Shadows Function ShowDialog() as DialogResult
End Function
'Create the ShowDialog method that I want people to use
Public Overloads Function ShowDialog(ByVal something As Whatever) as DialogResult
'Put some code here
'Now, I would like to show the Class as a Modal Form
'and wait for the user to press one of the "DialogResult" Buttons,
'but I don't know how to do that
'Put some more code here
'Indicate the Button that was pressed
Return Me.DialogResult
End Function
Thanks for any help!
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
|