Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to move the highlight colour in textbox word by word c#.net.
Posted
Updated 3-Apr-12 1:36am
v2

Try this for code for highlight the colour text in RichTextbox.
C#
Rtxt_box.Select(Start_Position, Length);
Rtxt_box.SelectionColor = Color.White;
Rtxt_box.SelectionBackColor = Color.Blue;
 
Share this answer
 
Comments
siri2012 4-Apr-12 0:10am    
getting error here (Start_Position, Length);
leena206 4-Apr-12 0:29am    
wht is an error??
give ur starting Position and total length..
leena206 4-Apr-12 0:33am    
Try this

Rtxt_box.SelectionLength(Start_Position, Length);
Rtxt_box.SelectionColor = Color.White;
Rtxt_box.SelectionBackColor = Color.Blue;
leena206 4-Apr-12 0:34am    
Refer this example
private void ModifySelectedText()
{
// Determine if text is selected in the control.
if (richTextBox1.SelectionLength > 0)
{
// Set the color of the selected text in the control.
richTextBox1.SelectionColor = Color.Red;
// Set the font of the selected text to bold and underlined.
richTextBox1.SelectionFont = new Font("Arial",10,FontStyle.Bold | FontStyle.Underline);
// Protect the selected text from modification.
richTextBox1.SelectionProtected = true;
}
}
Refer this link : For more details
http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.aspx
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900