Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6212021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:26:19+00:00 2026-05-24T06:26:19+00:00

I am developing a custom messagebox class like the following- Public Class MyCustomMsgBox Private

  • 0

I am developing a custom messagebox class like the following-

Public Class MyCustomMsgBox


    Private MyForm As Form = New Form
    Private lblHeadline As Label = New Label
    Private lblMessageBody As Label = New Label
    Private btnNo As Button = New Button
    Private btnOk As Button = New Button
    Private btnYes As Button = New Button

    Public Sub New(ByVal Message As String)
        With MyForm
            .Width = 438
            .Height = 214
            .Controls.AddRange(New Control() {lblHeadline, lblMessageBody, btnNo, btnYes, btnOk})
        End With
    End Sub

    Public Shared Function ShowErrorMsg(ByVal ErrorMessage As String) As     Windows.Forms.DialogResult
        Dim obj As MyCustomMsgBox = New MyCustomMsgBox(ErrorMessage)
        obj.MyForm.ShowDialog()
    End Sub

    Public Shared function ShowSuccessMsg(ByVal SuccessMessage As String) As     Windows.Forms.DialogResult
       'some code
    End Sub

    Public Shared Function AskQuestions(ByVal Questions As String) As Windows.Forms.DialogResult
       'some code
    End Sub

    Public Shared Function ShowExceptions(ByVal ExMessage As String) As Windows.Forms.DialogResult
       'some code
    End Sub


    'Private Sub btnNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNo.Click
    '  Windows.Forms.DialogResult.No()
    'End Sub

    End Class

Those functions are designed with related graphics, color, title and heading.

btnOk will return DialogResult.Ok, btnNo will return DialogResult.No and btnYes will return DialogResult.Yes

How do i return the dialog result with those functions?

How do i know that which button is pressed?

i dont know how to handle a button click event in a formless class.

Would you give me the idea?

Thank you in advance.

SKPaul

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:26:21+00:00Added an answer on May 24, 2026 at 6:26 am

    Start with the easy one. You will have to manually wire-up the events by using the AddHandler and RemoveHandler keywords this

    AddHandler btnNo.Click, AddressOf btnNo_Click
    

    btnNo is the button object. The “.Click” is the event you want captured. The AddressOf gets a pointer to the function (basically, it tells the compiler where the function is. Think of it as a different type of “handles”.)

    You’ll have to remvoe the handler when your done, by doing this.

    RemoveHandler btnNo.Click, AddressOf btnNo_Click
    

    To set the Dialog Results, the form must be called via ShowDialog. You Simple set the DialogResults property of the form. I’d do it in the form.closing event.

    me.DialogResult = Windows.Forms.DialogResult.OK
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a custom control that derives from CStatic MFC class (Smart Device
I'm developing custom Agent for LotusNotes 8.5. I'd like to use iCal4j jar to
I am developing a custom HttpHandler, to do so I write a C# Class
Background : I'm developing a custom regex-like syntax for URL filenames. It will work
I'm developing a custom HyperTerminal like application in a WinForms .Net 2.0 application. I
I am developing a custom component using JSF 1.2. My tag class extends UIComponentELTag
I am developing a custom LISP interpreter. It won't support defining functions like in
I'm developing a custom DataGridView control for internal use and I'd like to add
I'm developing a custom aspx form for a SharePoint list in Visual Studio, basically
I developing a custom manager class with chainable method. Got a problem. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.