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. Windows Forms
  4. Cursor control in Text Box

Cursor control in Text Box

Scheduled Pinned Locked Moved Windows Forms
winformsdesigntutorial
9 Posts 5 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.
  • S Offline
    S Offline
    sakthii
    wrote on last edited by
    #1

    I like to simulate Mobile UI using Windows Forms. I want some pointer to implement following features, 1. How to display cursor(horizontal cursor "_" and vertical cursor "|") inside text box control 2. How to get cursor position and move the cursor. Some one can also suggest whether TextBox control is enough for the above implementation or whether i should go with RichTextBox control thanks

    H U 2 Replies Last reply
    0
    • S sakthii

      I like to simulate Mobile UI using Windows Forms. I want some pointer to implement following features, 1. How to display cursor(horizontal cursor "_" and vertical cursor "|") inside text box control 2. How to get cursor position and move the cursor. Some one can also suggest whether TextBox control is enough for the above implementation or whether i should go with RichTextBox control thanks

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      Is bing broken where you are?

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      S B 2 Replies Last reply
      0
      • H Henry Minute

        Is bing broken where you are?

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        S Offline
        S Offline
        sakthii
        wrote on last edited by
        #3

        I am not getting you henry!

        M 1 Reply Last reply
        0
        • S sakthii

          I am not getting you henry!

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          bing = search engine Your questions have been asked 1000s of times before and a search will get you the answers quicker that asking a question in the forum. If you have not tried a search engine in the last 14 hours I suggest you do so. If bings is not working you may want to try google.

          Never underestimate the power of human stupidity RAH

          S 1 Reply Last reply
          0
          • M Mycroft Holmes

            bing = search engine Your questions have been asked 1000s of times before and a search will get you the answers quicker that asking a question in the forum. If you have not tried a search engine in the last 14 hours I suggest you do so. If bings is not working you may want to try google.

            Never underestimate the power of human stupidity RAH

            S Offline
            S Offline
            sakthii
            wrote on last edited by
            #5

            Thanks for your reply. I posted this query after searching through net and going through codeproject. There are many features available for WindowsCE! I am working on WindowsForms. I am hardcore C Programmer, I am introduced to C++ because of MFC/Visual Studio to create gui to my back end C program library. I am switching over from MFC to windows forms as i am informed that WF is easy than MFC. I am learning Windows Form now, and i see examples for VB, C# and C++. I prefer to use C++ as i can manage and understand the same compare to other. I created Windows Forms project using following options: File->New->Project->VC++(main option)->Windows Forms Application in Visual Studio 2008 professional edition. I really dont know whether C# or C++ is used by default by the VS2008 while creating the template! I looked into this site http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor(VS.71).aspx my requirement is I wish to change the cursor based on button press inside the text control and back to default on clicking another button. I used following code. private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { // creating new cursor System::Windows::Forms::Cursor= gcnew System::Windows::Forms::Cursor("MyCur.cur"); // this should set a cursor for all TextBox inside the form System::Windows::Forms::TextBox::Cursor::set(mycur); //setting the focus to textBox1 textBox1->Focus(); } // to get default cursor private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) { System::Windows::Forms::Cursor::Current = System::Windows::Forms::Cursors::Default; } Result: on button4 press, the whole form gets the new cursor. And the focus given to textBox1, with default cursor! on button5 press, it is not reverting back to default cursor.

            modified on Tuesday, June 2, 2009 8:51 AM

            H 1 Reply Last reply
            0
            • S sakthii

              Thanks for your reply. I posted this query after searching through net and going through codeproject. There are many features available for WindowsCE! I am working on WindowsForms. I am hardcore C Programmer, I am introduced to C++ because of MFC/Visual Studio to create gui to my back end C program library. I am switching over from MFC to windows forms as i am informed that WF is easy than MFC. I am learning Windows Form now, and i see examples for VB, C# and C++. I prefer to use C++ as i can manage and understand the same compare to other. I created Windows Forms project using following options: File->New->Project->VC++(main option)->Windows Forms Application in Visual Studio 2008 professional edition. I really dont know whether C# or C++ is used by default by the VS2008 while creating the template! I looked into this site http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor(VS.71).aspx my requirement is I wish to change the cursor based on button press inside the text control and back to default on clicking another button. I used following code. private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { // creating new cursor System::Windows::Forms::Cursor= gcnew System::Windows::Forms::Cursor("MyCur.cur"); // this should set a cursor for all TextBox inside the form System::Windows::Forms::TextBox::Cursor::set(mycur); //setting the focus to textBox1 textBox1->Focus(); } // to get default cursor private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) { System::Windows::Forms::Cursor::Current = System::Windows::Forms::Cursors::Default; } Result: on button4 press, the whole form gets the new cursor. And the focus given to textBox1, with default cursor! on button5 press, it is not reverting back to default cursor.

              modified on Tuesday, June 2, 2009 8:51 AM

              H Offline
              H Offline
              Henry Minute
              wrote on last edited by
              #6

              I have not used C++ since before the advent of Windows Forms, so I would not venture to attempt to offer you any code snippets. However speaking in Windows Forms terms, each TextBox instance has its own Cursor property and it is this that needs to be set. If you need to change the cursor for all TextBoxes on a Form/Control you will need to iterate over the Controls property of the Form/Control and test if the control is a TextBox and then set the Cursor property to the desired cursor. Since TextBox inherits the Cursor property from Control there is no need to cast before doing so. I hope that this helps, but if not perhaps someone with C++ skills will help you.

              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

              1 Reply Last reply
              0
              • S sakthii

                I like to simulate Mobile UI using Windows Forms. I want some pointer to implement following features, 1. How to display cursor(horizontal cursor "_" and vertical cursor "|") inside text box control 2. How to get cursor position and move the cursor. Some one can also suggest whether TextBox control is enough for the above implementation or whether i should go with RichTextBox control thanks

                U Offline
                U Offline
                Uwe Keim
                wrote on last edited by
                #7

                It is called "caret", not "cursor".

                • My personal 24/7 webcam • Zeta Test - Intuitive, competitive Test Management environment for Test Plans and Test Cases. Download now! • Zeta Producer Desktop CMS - Intuitive, very easy to use. Download now!

                B 1 Reply Last reply
                0
                • H Henry Minute

                  Is bing broken where you are?

                  Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                  B Offline
                  B Offline
                  Baeltazor
                  wrote on last edited by
                  #8

                  oh my god henry i love bing! i think it's way cooler that g%%gle!

                  1 Reply Last reply
                  0
                  • U Uwe Keim

                    It is called "caret", not "cursor".

                    • My personal 24/7 webcam • Zeta Test - Intuitive, competitive Test Management environment for Test Plans and Test Cases. Download now! • Zeta Producer Desktop CMS - Intuitive, very easy to use. Download now!

                    B Offline
                    B Offline
                    Baeltazor
                    wrote on last edited by
                    #9

                    Agreed.

                    Uwe Keim wrote:

                    caret

                    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