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. textbox cursor position

textbox cursor position

Scheduled Pinned Locked Moved C#
helpquestion
3 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.
  • P Offline
    P Offline
    PaulaM
    wrote on last edited by
    #1

    Hi, i have 2 textboxes txt1 and txt2 and a button(mybutton) which inserts variables into my textboxes. problem: i enter text into txt1 eg "my name is " and click on mybutton to enter a variable so that my variable appears right after the text i entered eg "my name is xVariable_namex". how do i let my button know which textbox it needs to enter the variable,in other words where the cursor position is. remember i have two textboxes hope you understand my question thanks for your help;) regards paula

    A _ 2 Replies Last reply
    0
    • P PaulaM

      Hi, i have 2 textboxes txt1 and txt2 and a button(mybutton) which inserts variables into my textboxes. problem: i enter text into txt1 eg "my name is " and click on mybutton to enter a variable so that my variable appears right after the text i entered eg "my name is xVariable_namex". how do i let my button know which textbox it needs to enter the variable,in other words where the cursor position is. remember i have two textboxes hope you understand my question thanks for your help;) regards paula

      A Offline
      A Offline
      AB7771
      wrote on last edited by
      #2

      just check the focused property of the textboxes and set the value in the one which has the focused property true. Regards, Pramod

      1 Reply Last reply
      0
      • P PaulaM

        Hi, i have 2 textboxes txt1 and txt2 and a button(mybutton) which inserts variables into my textboxes. problem: i enter text into txt1 eg "my name is " and click on mybutton to enter a variable so that my variable appears right after the text i entered eg "my name is xVariable_namex". how do i let my button know which textbox it needs to enter the variable,in other words where the cursor position is. remember i have two textboxes hope you understand my question thanks for your help;) regards paula

        _ Offline
        _ Offline
        _Bao_
        wrote on last edited by
        #3

        I'm not sure I understood well, but if you want to add the content of a variable to the textbox that contains some string, these should be helpful: check if your control has focus: control.Focused check if your textbox has some text in it: textbox.Text.Lenght textbox.Text != string.Empty appends new text to existing text: textbox.Text += "your new text";

        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