[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

selection location in RichTextBox

Posted on 2004-08-17
7
Medium Priority
?
280 Views
Last Modified: 2010-04-15
hi again experts,
i have a RichTextBox in which the user designs dumb terminal screens.  i've fixed the size so that it only allows 80 chars per line and a total of 24 lines.  after the user gets the screen (rtb) looking like they want it, i need my code to translate the screen into a file that desribes the layout of the screen.  in order to do this, i plan to scan the text by selecting each character one by one.  if i could detect a change in y-coordinate of the selected text, i could tell when a new line will need to be described.  any idea on how to do this?

thanks,

rye
0
Comment
Question by:ryeandi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 7

Expert Comment

by:NipNFriar_Tuck
ID: 11822763
In a RTB with multiple lines set at 80 characters you could look for \r\n to determine when a newline is entered.  Of course you will have to set the RTB to do hardreturns to ensure that the \r\n will be there...
0
 
LVL 1

Author Comment

by:ryeandi
ID: 11822812
how do you set the rtb to do hardreturns?
0
 
LVL 7

Expert Comment

by:NipNFriar_Tuck
ID: 11823035
There is a wordwrap property that you will want to set to false.  Also, the RTB does not use \r\n for the return rather it uses \n...

Also, if you have preprogramed in 24 lines at 80 characters you may be able to use the lines property on the RTB...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:ryeandi
ID: 11823308
thanks nipnfriar__tuck,
but what i'm really looking for is a way to know if the y-pos changed when scanning like in my original post.  i've been trying to use the method you describe but have found that too many variables come into play.  one problem is that i've sized my rtb to 80 characters using a fixed sized font.  turning off wordwrap causes the lines to expand.  if i use a word wrap and my method for controling the number of lines, all i need is to scan the rtb looking for change in y-pos and i'll know which line i'm on.  
0
 
LVL 1

Author Comment

by:ryeandi
ID: 11823611
actually i just figured it out myself.

Point pt;
int yCord = -1;
for(int i = 0; i < rtb.Text.Length; i++)
{
  pt = rtb.GetPositionFromCharIndex(i);
  if(yCord != pt.Y)
  {
    yCord = pt.Y;
    MessageBox.Show("Character: " + rtb.Text[i] + " starts a new line");
  }
}

thanks.  
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11859724
Closed, 100 points refunded.
Netminder
Site Admin
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question