decrypt Posted July 8, 2005 Posted July 8, 2005 (edited) I can't figure this one out. I have been searching all day on google, and I have found absolutely nothing. How could I SET the current line selected? Thanks in advanced! btw, scrolling a textbox: http://www.codeproject.com/vb/net/VbNetScrolling.asp Edited July 9, 2005 by decrypt Quote
pelikan Posted July 10, 2005 Posted July 10, 2005 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) Quote IN PARVUM MULTUM
decrypt Posted July 23, 2005 Author Posted July 23, 2005 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.. Quote
Leaders Iceplug Posted July 24, 2005 Leaders Posted July 24, 2005 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 Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
decrypt Posted July 24, 2005 Author Posted July 24, 2005 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.