Click here to Skip to main content
15,921,697 members
Home / Discussions / C#
   

C#

 
GeneralRe: IEndPoint Object Pin
Colin Angus Mackay23-Jun-04 0:33
Colin Angus Mackay23-Jun-04 0:33 
GeneralRe: IEndPoint Object Pin
dabuskol23-Jun-04 0:59
dabuskol23-Jun-04 0:59 
GeneralRe: IEndPoint Object Pin
Colin Angus Mackay23-Jun-04 1:19
Colin Angus Mackay23-Jun-04 1:19 
GeneralRe: IEndPoint Object Pin
dabuskol23-Jun-04 1:26
dabuskol23-Jun-04 1:26 
GeneralRe: IEndPoint Object Pin
Heath Stewart23-Jun-04 4:24
protectorHeath Stewart23-Jun-04 4:24 
GeneralHighlight a line that contains a string Pin
clatten22-Jun-04 23:49
clatten22-Jun-04 23:49 
GeneralRe: Highlight a line that contains a string Pin
LongRange.Shooter23-Jun-04 3:20
LongRange.Shooter23-Jun-04 3:20 
GeneralRe: Highlight a line that contains a string Pin
clatten23-Jun-04 11:44
clatten23-Jun-04 11:44 
OK, I tried that and it worked somehow but there's still a problem.

Given the code below I search for the string "string" and then select the line that contains the string "This is the string I search for". The result will be that string is replaced and highlighted and thus giving:

"This is the This is the string I search for I search for".

I have tried several solutions avoiding this, but I assume I need to use SelectedText.Replace or set Select to start from the beginning of the line
But I can't find out a way to calculate where the line starts and ends.

Anyone that can hint how to proceed?

private void WinForm_Load(object sender, System.EventArgs e)
{
richTextBox1.Text = "Hello world\n";
richTextBox1.AppendText("This is the string I search for\n");
richTextBox1.AppendText("The last row\n");
}

}

private void button1_Click(object sender, System.EventArgs e)
{
int locate = richTextBox1.Find("string");

int line = richTextBox1.GetLineFromCharIndex(locate);
richTextBox1.SelectionColor = Color.Red;
richTextBox1.SelectedText = richTextBox1.Lines[line];
string q = richTextBox1.Lines[line];;
richTextBox1.SelectionProtected = true;
int len = richTextBox1.Lines[line].Length;
string txt = richTextBox1.Lines[line];
richTextBox1.SelectionCharOffset = 5;
richTextBox1.AppendText("Line no: " + line + ", Locate: " + locate + ", Len: " + len + "\n");
richTextBox1.AppendText(txt + "\n");
richTextBox1.AppendText("q: " + q);
}
GeneralRe: Highlight a line that contains a string Pin
clatten23-Jun-04 21:57
clatten23-Jun-04 21:57 
GeneralRequired permissions cannot be acquired Pin
Daniel Zaharia22-Jun-04 23:25
Daniel Zaharia22-Jun-04 23:25 
GeneralRe: Required permissions cannot be acquired Pin
Jochen Kalmbach [MVP VC++]23-Jun-04 0:44
Jochen Kalmbach [MVP VC++]23-Jun-04 0:44 
GeneralRe: Required permissions cannot be acquired Pin
Daniel Zaharia23-Jun-04 1:37
Daniel Zaharia23-Jun-04 1:37 
GeneralRe: Required permissions cannot be acquired Pin
Jochen Kalmbach [MVP VC++]23-Jun-04 1:57
Jochen Kalmbach [MVP VC++]23-Jun-04 1:57 
GeneralRe: Required permissions cannot be acquired Pin
Heath Stewart23-Jun-04 4:19
protectorHeath Stewart23-Jun-04 4:19 
GeneralRe: Required permissions cannot be acquired Pin
Daniel Zaharia23-Jun-04 4:37
Daniel Zaharia23-Jun-04 4:37 
GeneralRe: Required permissions cannot be acquired Pin
Daniel Zaharia23-Jun-04 2:06
Daniel Zaharia23-Jun-04 2:06 
GeneralRegistration page woes Pin
diptea22-Jun-04 23:18
diptea22-Jun-04 23:18 
GeneralRe: Registration page woes Pin
Colin Angus Mackay22-Jun-04 23:39
Colin Angus Mackay22-Jun-04 23:39 
GeneralTo add a style in datagrid Pin
HowRU22-Jun-04 23:05
HowRU22-Jun-04 23:05 
GeneralRe: To add a style in datagrid Pin
Dave Kreskowiak23-Jun-04 4:05
mveDave Kreskowiak23-Jun-04 4:05 
GeneralA question about VBA and C# Pin
Member 94012522-Jun-04 22:34
Member 94012522-Jun-04 22:34 
GeneralRe: A question about VBA and C# Pin
Heath Stewart23-Jun-04 4:06
protectorHeath Stewart23-Jun-04 4:06 
GeneralQ: Coloring Schemes Pin
yoaz22-Jun-04 22:08
yoaz22-Jun-04 22:08 
GeneralRe: Q: Coloring Schemes Pin
Daniel M. Edwards23-Jun-04 3:02
Daniel M. Edwards23-Jun-04 3:02 
GeneralRe: Q: Coloring Schemes Pin
yoaz23-Jun-04 4:29
yoaz23-Jun-04 4:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.