Solved

Custom DialogResult

Posted on 2006-06-13
3
805 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
  • 2
3 Comments
 
LVL 85

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now