Results 1 to 6 of 6

Thread: [RESOLVED] Message box

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    100

    Resolved [RESOLVED] Message box

    Is there any way to display a messagebox with a question in it when a form starts up?

  2. #2
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    831

    Re: Message box

    by a question, you mean a text question and a field to answer it ? ( a bit like the former input box) or just a text with a question in it?

    if it is the first , create a small form with a label and a textbox and call the form.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,606

    Re: Message box

    Please provide a FULL and CLEAR explanation of the problem. Of course you can display a question in a message box. It's just text like any other, so why would it be different? If what you're actually asking is how can the user answer the question then that's different. Say what you actually mean because, if you actually mean what you said then there's no problem to be solved.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,199

    Re: Message box

    You can display a MsgBox with a question on startup. You can specify options such as iconquestion and messageboxbuttons.yesno and defaultbutton etc…

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    100

    Re: Message box

    I was able to display the messagebox when the form started.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,606

    Re: Message box

    Quote Originally Posted by wideminnow6970 View Post
    I was able to display the messagebox when the form started.
    That seems to suggest that your issue was more about doing something when a form was opened rather than about a message box. As you haven't actually specified what your solution was, so it can't help anyone else and we also don't know whether there's a better option, I'll provide options for that.

    A form has a Load event and a Shown event. The former is raised just before the form is displayed for the first time and the latter is displayed just after. If you want something to happen at those moments in the form's lifecycle, do it in the appropriate event handler. Note that, once you call Show/ShowDialog and the Load event is raised, the form is going to be displayed. If you're asking the user a question that will affect whether or not you want the form displayed, you need to do it before calling Show/ShowDialog in the first place. If you want to do something before the application's startup form is created, handle the Startup event of the application. That allows you to cancel the event and exit the application without ever creating the startup form is you desire.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width