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. Turning off the insertion point.

Turning off the insertion point.

Scheduled Pinned Locked Moved C#
questioncsharphelp
12 Posts 6 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.
  • J Jamestown48

    Hi, everybody. Could anyone help me with this subtle and foolish question? My question is: How do you turn on and off the insertion point(blinking cursor)like in TextBox in C#? Thanks.

    P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #3

    Are you using a TextBox? Designing your own control? What? Do you want it off? Or blinking?

    J 1 Reply Last reply
    0
    • P PIEBALDconsult

      Are you using a TextBox? Designing your own control? What? Do you want it off? Or blinking?

      J Offline
      J Offline
      Jamestown48
      wrote on last edited by
      #4

      No, I am justing creating a window form and dragged/dropped a TextBox onto the form. And when the form in running I want to hold the insertion point off until user clicks either (EDIT) or (Add) button is clicked. At that point I want the user click any Input TextBox to type in any data the user desires in the TextBox. As you all expect, as soon as the window is running and when you click the TextBox, eventhough no (EDIT) or (ADD) button is clicked, you will see the cursor (inertion point) is blinking ready to accept the input. I want the cusor to be off until the user clicks either (EDIT) or (ADD) is clicked. Is my description clear enough? Thanks.

      L J 2 Replies Last reply
      0
      • J Jamestown48

        No, I am justing creating a window form and dragged/dropped a TextBox onto the form. And when the form in running I want to hold the insertion point off until user clicks either (EDIT) or (Add) button is clicked. At that point I want the user click any Input TextBox to type in any data the user desires in the TextBox. As you all expect, as soon as the window is running and when you click the TextBox, eventhough no (EDIT) or (ADD) button is clicked, you will see the cursor (inertion point) is blinking ready to accept the input. I want the cusor to be off until the user clicks either (EDIT) or (ADD) is clicked. Is my description clear enough? Thanks.

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

        Seems you want TextBox.Enabled=false or even TextBox.Visible=false until (EDIT) or (ADD) are clicked. :)

        Luc Pattyn

        J 1 Reply Last reply
        0
        • L Luc Pattyn

          Seems you want TextBox.Enabled=false or even TextBox.Visible=false until (EDIT) or (ADD) are clicked. :)

          Luc Pattyn

          J Offline
          J Offline
          Jamestown48
          wrote on last edited by
          #6

          Not exactly. I know TextBox.Visble=false; and TextBox.Enabled=true; This is not exactly what I want. Specifically after you creating a TextBox and when you run the form you'll see the cursor is blinking in the TextBox. ( when there is only one TextBox in the form for example). I want to turn off the blinking cursor off or make it disappear for certain period of time until the user do somthing. That's all I want. It seems so simple but I could not find anything about it in C#. Thanks.

          P D 2 Replies Last reply
          0
          • J Jamestown48

            No, I am justing creating a window form and dragged/dropped a TextBox onto the form. And when the form in running I want to hold the insertion point off until user clicks either (EDIT) or (Add) button is clicked. At that point I want the user click any Input TextBox to type in any data the user desires in the TextBox. As you all expect, as soon as the window is running and when you click the TextBox, eventhough no (EDIT) or (ADD) button is clicked, you will see the cursor (inertion point) is blinking ready to accept the input. I want the cusor to be off until the user clicks either (EDIT) or (ADD) is clicked. Is my description clear enough? Thanks.

            J Offline
            J Offline
            jk chan
            wrote on last edited by
            #7

            Suppose your form has 3 controls . one edit box ,and 2 other buttons. put tabindex of one of the buttons to zero in the form load event. So that the button will get focused. Hopes this helps.:-D

            If u can Dream... U can do it

            J 1 Reply Last reply
            0
            • J jk chan

              Suppose your form has 3 controls . one edit box ,and 2 other buttons. put tabindex of one of the buttons to zero in the form load event. So that the button will get focused. Hopes this helps.:-D

              If u can Dream... U can do it

              J Offline
              J Offline
              Jamestown48
              wrote on last edited by
              #8

              If you do that way the focus is certainly on one of the buttons. But at that moment if click the TextBox you will see the blinking cusor in the TextBox. This is not what I want. I don't want the blicking cursor show up in the TextBox until I click either (ADD) or (EDIT) button is clicked. Is this clear to you? Thanks.

              J 1 Reply Last reply
              0
              • J Jamestown48

                If you do that way the focus is certainly on one of the buttons. But at that moment if click the TextBox you will see the blinking cusor in the TextBox. This is not what I want. I don't want the blicking cursor show up in the TextBox until I click either (ADD) or (EDIT) button is clicked. Is this clear to you? Thanks.

                J Offline
                J Offline
                jk chan
                wrote on last edited by
                #9

                i understood now. So try changing focus on Textbox1_mouseclick , like below private void textBox1_MouseClick(object sender, MouseEventArgs e) { fousButton.Focus(); } In my case it workd. however it is not a good solution. i am searching for some other good solution with IMessageFilter. :-D

                If u can Dream... U can do it

                J 1 Reply Last reply
                0
                • J jk chan

                  i understood now. So try changing focus on Textbox1_mouseclick , like below private void textBox1_MouseClick(object sender, MouseEventArgs e) { fousButton.Focus(); } In my case it workd. however it is not a good solution. i am searching for some other good solution with IMessageFilter. :-D

                  If u can Dream... U can do it

                  J Offline
                  J Offline
                  jk chan
                  wrote on last edited by
                  #10

                  hi I tested it with IMessageFilter. Its working fine. Try adding a MessageFilter using Application.AddMessageFilter(new TestMessageFilter()); in class TestMessageFilter handle the mouse Down message(WM_LBUTTONDOWN) like this public class TestMessageFilter : IMessageFilter { public bool PreFilterMessage(ref Message m) { // Blocksmessages relating to left ms button. if (m.Msg == 0x0201)//WM_LBUTTONDOWN { Control c = Control.FromHandle(m.HWnd); if(c.Name =="textBox1") // ur textbox name return true; } return false; } } Hopes this helps

                  If u can Dream... U can do it

                  1 Reply Last reply
                  0
                  • J Jamestown48

                    Not exactly. I know TextBox.Visble=false; and TextBox.Enabled=true; This is not exactly what I want. Specifically after you creating a TextBox and when you run the form you'll see the cursor is blinking in the TextBox. ( when there is only one TextBox in the form for example). I want to turn off the blinking cursor off or make it disappear for certain period of time until the user do somthing. That's all I want. It seems so simple but I could not find anything about it in C#. Thanks.

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #11

                    I'd use Enabled=false, while disabled the TextBox won't get Focus.

                    1 Reply Last reply
                    0
                    • J Jamestown48

                      Not exactly. I know TextBox.Visble=false; and TextBox.Enabled=true; This is not exactly what I want. Specifically after you creating a TextBox and when you run the form you'll see the cursor is blinking in the TextBox. ( when there is only one TextBox in the form for example). I want to turn off the blinking cursor off or make it disappear for certain period of time until the user do somthing. That's all I want. It seems so simple but I could not find anything about it in C#. Thanks.

                      D Offline
                      D Offline
                      dbetting
                      wrote on last edited by
                      #12

                      I understand you would like to have TextBox.Enabled=true but if you are trying to control the user's actions, you need to make it very clear to them what is expected. Upon loading or clearing the form, set the data entry controls read-only. Then upon clicking the [Add], [Edit] or whatever the button is called, the first thing you do is enable your text boxes, radiobuttons and any other controls the user is to access for data entry. If you just hide the cursor, the user clicks on the TextBox and says "What's wrong? The cursor disappeared!" If it is disabled, it is pretty clear the only option they have is to tell the program what they want to do such as [Add], [Edit], etc. I usually have two core methods in most of my forms: Clear() and SetReadOnly(bool value). Upon loading the form or saving a record Clear() is called which sets all the default values for the fields. One of the last lines in Clear() is the call SetReadOnly(true); to disable all the controls. The only option the user has at this point is to click [New] or [Cancel]. If they click [New], I call SetReadOnly(false); and set the focus on the first field I want them to fill in (i.e. TextBox.SetFocus();). Just a suggestion.

                      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