Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

a) get the char index of the line by sending message EM_LINEINDEX

b) set the selection to that point in the control (or the whole line EM_LINELENGTH) with EM_SETSEL or Select(int index, int lenght)

IN PARVUM MULTUM
  • 2 weeks later...
Posted
I finally got round to trying this out (because I've been gone on holiday). What I really want to do is have an integer, and go to the line of the inputed integer. It's sort of like when you press ctrl+G in microsoft word, notepad, etc..
  • Leaders
Posted

How about this:

When you get an integer, extract the line that matches this integer,

then use .IndexOf to find the location of this line within the textbox.

 

Or you can use an .IndexOf loop.

x is an integer, and LN is a copy of the integer that tells which line to go to
LN -= 1
x = 0
Do Until LN = 0
x = yourtext.IndexOf(Convert.ToChar(10), x)
Convert.ToChar(10) is supposed to be the linefeed.
LN -= 1
Go Back To The Do

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted

Thanks a lot!

 

here is the code:

 

       LN = UserInput - 1 'you have to do this, otherwise it will select the next line
       X = 0
       Do
           X = txtMain.Text.IndexOfAny(System.Environment.NewLine, X + 1)
           LN -= 1
       Loop Until LN = 0
       txtMain.Select(X + 1, 0) 'do this so it doesn't select the end of the line before

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...