[.net] How to select/HIGHLIGHT one line in a multiline textBox?
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..
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.
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.
Can you please tell me?
Thank you.
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.
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..
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..
It might be easier if you write a custom control instead of trying to force a textbox to behave a certain way.
In a multiline textbox each line ends with Environment.NewLine or "\r\n".
So an empty line would be Environment.NewLine or "\r\n".
So an empty line would be Environment.NewLine or "\r\n".
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement