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. Textbox event to know if text is selected?

Textbox event to know if text is selected?

Scheduled Pinned Locked Moved Windows Forms
question
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.
  • F Offline
    F Offline
    fredsparkle
    wrote on last edited by
    #1

    Hi Everyone I have upper level framework that needs to be notified when the user has selected text in a regular textbox. There doesn't seem to be a event to signals that the selected text value has changed. Any suggestions other then a timer that polls the control? Thanks

    M R 2 Replies Last reply
    0
    • F fredsparkle

      Hi Everyone I have upper level framework that needs to be notified when the user has selected text in a regular textbox. There doesn't seem to be a event to signals that the selected text value has changed. Any suggestions other then a timer that polls the control? Thanks

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

      I think your right, there is no event for selected text, you would have to use key/mouse events or possibly on leave

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • F fredsparkle

        Hi Everyone I have upper level framework that needs to be notified when the user has selected text in a regular textbox. There doesn't seem to be a event to signals that the selected text value has changed. Any suggestions other then a timer that polls the control? Thanks

        R Offline
        R Offline
        Richard Blythe
        wrote on last edited by
        #3

        The quickest way to implement this would be with the MouseUp event. Try this approach: private int selectedTextLength = 0; private int selectionStart = 0; private void textBox1_MouseUp(object sender, MouseEventArgs e) { if (selectionStart != textBox1.SelectionStart || selectedTextLength != textBox1.SelectionLength) { selectionStart = textBox1.SelectionStart; selectedTextLength = textBox1.SelectionLength; //notify framwork... } } Cheers! Richard Blythe

        "Make it as simple as possible, but no simpler" Issac Newton

        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