Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. MessageBox with a timer?

MessageBox with a timer?

Scheduled Pinned Locked Moved C#
csharpmobilehelpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vertekal
    wrote on last edited by
    #1

    How would I add a timer to this? To keep things simple, I have a form with 1 button and 1 textbox. I have a messagebox that pops up when the textbox loses focus ... if the user clicks OK, it does something. However, if the user doesn't click OK within 3 seconds, I need the box to close and do something else. This is for a mobile app using .NETCF 3.5. Here's what I have so far in regards to the messagebox: private void TextBox1_LostFocus(object sender, EventArgs e) { DialogResult result = MessageBox.show("message text","title",MessageBoxButtons.OK,MessageBoxIcon.None,MessageBoxDefaultButton.Button1): if (result == DialogResult.OK) { Button1.Focus(); } else { //Close messagebox and do some other things if 3 seconds have elapsed and OK was not clicked } } Any help would be appreciated! Thanks!

    J L 2 Replies Last reply
    0
    • V Vertekal

      How would I add a timer to this? To keep things simple, I have a form with 1 button and 1 textbox. I have a messagebox that pops up when the textbox loses focus ... if the user clicks OK, it does something. However, if the user doesn't click OK within 3 seconds, I need the box to close and do something else. This is for a mobile app using .NETCF 3.5. Here's what I have so far in regards to the messagebox: private void TextBox1_LostFocus(object sender, EventArgs e) { DialogResult result = MessageBox.show("message text","title",MessageBoxButtons.OK,MessageBoxIcon.None,MessageBoxDefaultButton.Button1): if (result == DialogResult.OK) { Button1.Focus(); } else { //Close messagebox and do some other things if 3 seconds have elapsed and OK was not clicked } } Any help would be appreciated! Thanks!

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      Most likely you'll need to create a Form that looks like a message box that has a timer on it. The built-in MessageBox is not very customizable outside of the text and icons.

      V 1 Reply Last reply
      0
      • V Vertekal

        How would I add a timer to this? To keep things simple, I have a form with 1 button and 1 textbox. I have a messagebox that pops up when the textbox loses focus ... if the user clicks OK, it does something. However, if the user doesn't click OK within 3 seconds, I need the box to close and do something else. This is for a mobile app using .NETCF 3.5. Here's what I have so far in regards to the messagebox: private void TextBox1_LostFocus(object sender, EventArgs e) { DialogResult result = MessageBox.show("message text","title",MessageBoxButtons.OK,MessageBoxIcon.None,MessageBoxDefaultButton.Button1): if (result == DialogResult.OK) { Button1.Focus(); } else { //Close messagebox and do some other things if 3 seconds have elapsed and OK was not clicked } } Any help would be appreciated! Thanks!

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, this has been handled before: http://www.codeproject.com/info/search.aspx?artkw=messagebox+timer&sbo=kw[^] :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


        V 1 Reply Last reply
        0
        • L Luc Pattyn

          Hi, this has been handled before: http://www.codeproject.com/info/search.aspx?artkw=messagebox+timer&sbo=kw[^] :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


          V Offline
          V Offline
          Vertekal
          wrote on last edited by
          #4

          I did search a bit first, but the first few answers were in VB or C++. I was hoping for C# examples. I did look further on the results and came across http://www.codeproject.com/KB/cs/A_Custom_Message_Box.aspx[^] which might be helpful. Thanks!

          L 1 Reply Last reply
          0
          • J Judah Gabriel Himango

            Most likely you'll need to create a Form that looks like a message box that has a timer on it. The built-in MessageBox is not very customizable outside of the text and icons.

            V Offline
            V Offline
            Vertekal
            wrote on last edited by
            #5

            That's what I'm looking at, based on http://www.codeproject.com/KB/cs/A_Custom_Message_Box.aspx[^] I'm just trying to determine the best way to use it for my specific needs. Thanks!

            1 Reply Last reply
            0
            • V Vertekal

              I did search a bit first, but the first few answers were in VB or C++. I was hoping for C# examples. I did look further on the results and came across http://www.codeproject.com/KB/cs/A_Custom_Message_Box.aspx[^] which might be helpful. Thanks!

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Hi, why is language that important? to learn concepts just read the text and look at the program structure and the classes/methods used. if you can write C# I trust you can also read VB code? :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


              V 1 Reply Last reply
              0
              • L Luc Pattyn

                Hi, why is language that important? to learn concepts just read the text and look at the program structure and the classes/methods used. if you can write C# I trust you can also read VB code? :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


                V Offline
                V Offline
                Vertekal
                wrote on last edited by
                #7

                I can (sorta) comprehend what the VB code is trying to do, yes.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups