Solved

Custom DialogResult

Posted on 2006-06-13
3
821 Views
Last Modified: 2012-08-13
is there anyway to have a custom result from a dialog?

instead of dialogresult.OK, dialogresult.cancel, etc,

could i create a custom result like DialogResult.PasswordOK?

thanks
0
Comment
Question by:newyuppie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 16898502
Usage:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Form1.MyShowDialog = MyResult.PasswordOK Then
            MsgBox("Password Accepted")
        Else
            MsgBox("Password Failed")
        End If
    End Sub



...and here is Form1...



Public Class Form1

    Public Enum MyResult
        PasswordOK
        PasswordInvalid
    End Enum

    Private result As Form1.MyResult

    Public ReadOnly Property MyDialogResult()
        Get
            Return result
        End Get
    End Property

    Public Shared Function MyShowDialog() As Form1.MyResult
        Dim f1 As New Form1
        f1.ControlBox = False
        f1.ShowDialog()
        Return f1.MyDialogResult
    End Function

    Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        If TextBox1.Text = "something" Then
            result = MyResult.PasswordOK
        Else
            result = MyResult.PasswordInvalid
        End If
        Me.Hide()
    End Sub

End Class
0
 
LVL 13

Author Comment

by:newyuppie
ID: 16973057
sorry for posting so late, you answered very promptly. i am checking that code right now and will award you the points if its working
0
 
LVL 13

Author Comment

by:newyuppie
ID: 16986779
idle_mind sorry for the delay i had to urgently take care of another business...

i tried the code and it does the trick for me, thank you very much for posting the full code! you get the points
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question