hi all, I am able to highlight the syntax when I type the text ie c# code in richtextbox using the following code code: // Calculate the starting position of the current line. int start = 0, end = 0; for (start = richTextBox1.SelectionStart - 1; start > 0; start--) { if (richTextBox1.Text[start] == '\n') { start++; break; } } // Calculate the end position of the current line. for (end = richTextBox1.SelectionStart; end < richTextBox1.Text.Length; end++) { if (richTextBox1.Text[end] == '\n') break; } // Extract the current line that is being edited. String line = richTextBox1.Text.Substring(start, end - start); // Backup the users current selection point. int selectionStart = richTextBox1.SelectionStart; int selectionLength = richTextBox1.SelectionLength; // Split the line into tokens. Regex r = new Regex("([ \\t{}();])"); string [] tokens = r.Split(line); int index = start; foreach (string token in tokens) { // Set the token's default color and font. richTextBox1.SelectionStart = index; richTextBox1.SelectionLength = token.Length; richTextBox1.SelectionColor = Color.Black; richTextBox1.SelectionFont = new Font("Courier New", 10, FontStyle.Regular); // Check whether the token is a keyword. String [] keywords = {"abstract","base","bool","break","byte","case","catch",,...."using","virtual","void" }; for (int i = 0; i < keywords.Length; i++) { if (keywords[i] == token) { // Apply alternative color and font to highlight keyword. richTextBox1.SelectionColor = Color.Blue; richTextBox1.SelectionFont = new Font("Courier New", 10, FontStyle.Bold); break; } } index += token.Length; } // Restore the users current selection point. richTextBox1.SelectionStart = selectionStart; richTextBox1.SelectionLength = selectionLength; But my aim is to write c# code in text file and load that text file into a richtext