Jump to content
  • Advertisement
Sign in to follow this  
chrisliando

[.net] How to select/HIGHLIGHT one line in a multiline textBox?

This topic is 3802 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My application is a text comparer consists of Source textBox and Target textBox. After I found differences of Source file and Target file, I put them in a listView with format like this: Line # | Source File | Target File | ------------------------------------------ Line 2 | eat | sleep | Line 5 | Nevada | Los Angeles | if users double-click on one of the item above, the focus / active cursor will DIRECTLY point to the Source textBox and/or Target textBox which LINE containing those words. And that LINE will be HIGHLIGHTED. If it is not possible to HIGHLIGHT 2 textBoxes at the same time, how to HIGHLIGHT 1 textBox only? Thank you very much..

Share this post


Link to post
Share on other sites
Advertisement
Have you looked at how Visual SourceSafe (or similar tool) works? If not, I recommend doing so before posting more questions. This is like the 10th question you've posted on this topic.

Share this post


Link to post
Share on other sites
Yes, I have looked at Visual Source Safe, WinMerge and WinDiff. I knew how they worked, but I don't know how to implement that in my app..

Can you please tell me?

Thank you.

Share this post


Link to post
Share on other sites
You need to at least try to do something yourself instead of just posting multiple questions about the same thing and expecting people to do it for you.

Share this post


Link to post
Share on other sites
I look for the difference and saved the line number as a listView item and when user want to point the difference, I did this on the listView1_DoubleClick event:

txtSource is the Source textBox, txtDest is the Destination textBox.

tmp is a int variable to get the listView item containing line number.



array<Char>^ chars = {' '};
array<String^>^ ln = item->Text->Split(chars);

int tmp = Convert::ToInt32(ln[1]) - 1;

txtSource->HideSelection = false;
txtSource->Select(txtSource->GetFirstCharIndexFromLine(tmp),txtSource->Lines[tmp]->Length);
txtSource->ScrollToCaret();
txtDest->Focus();
txtDest->HideSelection = false;
txtDest->Select(txtDest->GetFirstCharIndexFromLine(tmp),txtDest->Lines[tmp]->Length);
txtDest->ScrollToCaret();
listView1->HideSelection = false;
listView1->Select();

The result was: the codes has pointed to both textBox at the same time but just highlight the line containing character..

I still cannot select empty line, I don't know what an empty line contains? Is it " " or "\n" or empty String or null?

And I still cannot select one line full from left side of the textBox to the right side of the textBox.

How to do that?

Thank you very much..

Share this post


Link to post
Share on other sites
It might be easier if you write a custom control instead of trying to force a textbox to behave a certain way.

Share this post


Link to post
Share on other sites
In a multiline textbox each line ends with Environment.NewLine or "\r\n".

So an empty line would be Environment.NewLine or "\r\n".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!