#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11

    Changing the cursor location in a text ?


    I have a ComboBox, I have a KeyUp events on it. soo it's add the letter then it do something and come back to it. but when it's comeback from the function it was called, the cursor goes to the end. That's problematic

    exemple :

    you want to enter montreal

    you will press the letters

    m -> m
    o - > om
    n -> nom
    t -> tnom

    do you understand my problem ! that's why I need to find a way to change the cursor place soo when it's comeback, the cursor will be at the end of the text and not in front !

    any body got any idea ?
  2. #2
  3. Psycho Canadian
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jan 2001
    Location
    Canada
    Posts
    4,846
    Rep Power
    635
    from your example the text is coming back to the front and not the end, unless you read text right to left

    I just tested it, (vb.net? or you doing C#?) I put a keyup event and it typed correctly, or do you want it to go back to remove everything in the box each time?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11
    I am in vb


    Code:
        Private Sub CboCritere_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cboCritere.KeyUp
    
            mdlFonctions.CompleterListeRecherche(cboCritere, cboChamp.Text.ToLower)
    
            'Go the end of the combobox
    
        End Sub
    soo you said it's going in the back. Yet that's what it's suppose to do. but in my case it's look like it's not doing it.

    may be cause cboCritere is being passed by REF, and then when the function is returned, it's have losed his cursor place . Soo I would need to find a way to get the cursor in the back. I don't want to remove anything from what's there.


    btw : thank you for your help.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11
    Alright I found the answer for this one. Damn me, I forgot that the property SelectionStart existed lol.

    soo it was an easy job !
    cboCritere.SelectionStart = cboCritere.Text.Length

    damn myself lol
  8. #5
  9. Psycho Canadian
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jan 2001
    Location
    Canada
    Posts
    4,846
    Rep Power
    635
    it's always nice to fine the problems

IMN logo majestic logo threadwatch logo seochat tools logo