CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2003
    Location
    Japan
    Posts
    120

    Question How can I insert a string in target cursor?

    Hi, everybody..
    How can I insert a text into a string randomly...

    e.g. there a string "Hello, Friend" in the textbox.

    If I move a cursor within "Hello," and "Friend",
    can I insert a text "Dear" immediately within the string?

    How to do that? any function can get the cursor position within a String????

    Thanks for your help.

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    for example you can use Insert, take the IndexOf etc..
    string has lots of methods in it.

    string s = "Hello, Friend";
    s = s.Insert(6,"Dear");
    MessageBox.Show(s);

    Paresh
    - Software Architect

  3. #3
    Join Date
    Mar 2003
    Location
    Japan
    Posts
    120
    Thank you Paresh,

    Actaully, I know this insert method,

    But I want to know where is the cursor position within the string, so that I can use .insert(position,string)....

    hikki

  4. #4
    Join Date
    Nov 2002
    Location
    Tatooine
    Posts
    155
    If you want the position of the caret in the textbox... try

    textBox1.SelectionStart
    That which does not kill us, only makes us stronger.

    MCSD .NET

  5. #5
    Join Date
    Mar 2003
    Location
    Japan
    Posts
    120

    Thumbs up

    oh good...
    unbelievable !!

    Thanks a lot... wolfofthenorth.

  6. #6
    Join Date
    Nov 2002
    Location
    Tatooine
    Posts
    155
    Glad I could help.
    That which does not kill us, only makes us stronger.

    MCSD .NET

  7. #7
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    you will need to look more in Richtextbox, the members are sufficient for your basic needs of selection and insertion.
    you will also need to look in string members and methods.

    Paresh
    - Software Architect

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured