Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, I have all the line numbers from the RichTextBox in an array.....

Now, I need to know:

 

1.) How to programmatically move to a certain line

 

2.) Select that line

 

3.) Un-Select that line

 

Hope I'm not being too much of a pain to you guys. There is more to learn about the RTB than there is information out there about it..... I would like to see a site setup just for is using VB.NET

 

By the way, I use VB .NET

 

Fart:-\

Posted (edited)

I do not think there is some sort of simple possibility selecting lines from multiline-controls :( just by using a linenumber

 

But you could try and get the position of the first and last charakter of your rtb-line. Then there should be some kind of Method called Select(startingindex,endindex) and Unselect.

 

Can't give you any code as I'm not having some VS.net near :(

 

Hope this helps a little

 

Voca

 

_____

Errors are default. Anybody finding one may keep, sell or do whatever he or she may want to do with it ;)

Edited by Voca
Posted

Can someone convert this it VB.NET for me? I found it in the FAQ at the top of the fourm. I guess he thought everyone used C#

 

private void GoToLineAndColumn(RichTextBox RTB, int Line, int Column) 
    {  
         int offset = 0;  
         for (int i = 0; i < Line - 1 && i < RTB.Lines.Length; i++)  
         {  
              offset += RTB.Lines[i].Length + 1;  
         }  
         RTB.Focus();  
         RTB.Select(offset + Column, 0);  
    } 

 

Fart:-\

  • Moderators
Posted
Private sub GoToLineAndColumn(RTB as RichTextBox , Line as integer, Column as integer) 
      
         dim offset as integer = 0
         dim i as integer = 0
         For i = 0  to Line - 1  
                 if i < RTB.Lines.Length then
                      offset += RTB.Lines(i).Length + 1
                end if
         next  
         RTB.Focus() 
         RTB.Select(offset + Column, 0)
end sub

Visit...Bassic Software
Posted
Can someone convert this it VB.NET for me? I found it in the FAQ at the top of the fourm. I guess he thought everyone used C#

 

private void GoToLineAndColumn(RichTextBox RTB, int Line, int Column) 
    {  
         int offset = 0;  
         for (int i = 0; i < Line - 1 && i < RTB.Lines.Length; i++)  
         {  
              offset += RTB.Lines[i].Length + 1;  
         }  
         RTB.Focus();  
         RTB.Select(offset + Column, 0);  
    } 

 

Fart:-\

 

try this translator next time too bad I always need it vice versa :D

Debug me...

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...