Click here to Skip to main content
16,005,178 members
Home / Discussions / C#
   

C#

 
GeneralRe: .NET2 + Serial Port + Service Pin
Dave Kreskowiak22-Jun-05 5:00
mveDave Kreskowiak22-Jun-05 5:00 
GeneralRe: .NET2 + Serial Port + Service Pin
g00fyman22-Jun-05 12:04
g00fyman22-Jun-05 12:04 
GeneralRe: .NET2 + Serial Port + Service Pin
g00fyman22-Jun-05 12:23
g00fyman22-Jun-05 12:23 
GeneralA strange problem .......Help me please...I can't stand any more... Pin
Khanh Duy21-Jun-05 16:50
Khanh Duy21-Jun-05 16:50 
Generala gui refresh question Pin
cchere21-Jun-05 16:29
cchere21-Jun-05 16:29 
GeneralRe: a gui refresh question Pin
mav.northwind21-Jun-05 20:14
mav.northwind21-Jun-05 20:14 
GeneralRe: a gui refresh question Pin
S. Senthil Kumar21-Jun-05 20:46
S. Senthil Kumar21-Jun-05 20:46 
GeneralRegular Expression Code for Syntax Highlighting Pin
C_Simpkins21-Jun-05 14:14
C_Simpkins21-Jun-05 14:14 
Hello all,

I am trying to develop a text editor that highlights syntax for a statistical software package. I have created an xml file from which all of the keywords are loaded into five separate ArrayLists that each contain one type of syntax that will be highlighted in a rich text box on the main form. Here is the regular expression code that I am using for each of these ArrayLists to color the text when an existing document is opened in the rich text box:

foreach (object keyword in commandAL)<br />
			{<br />
				string kw = (string)keyword;<br />
				string searchstring = @"(?<=\s+)" + kw + @"(?=\s+)";<br />
				Regex re = new Regex(searchstring, RegexOptions.IgnoreCase |  RegexOptions.Multiline|RegexOptions.Compiled);<br />
				MatchCollection mc = re.Matches(richTextBoxDo.Text, 0);<br />
<br />
				foreach (Match foundmatch in mc)<br />
				{<br />
					int startposition = foundmatch.Index;<br />
					int length = foundmatch.Length;<br />
					richTextBoxDo.Select(startposition, length);<br />
					richTextBoxDo.SelectionColor = settings.SyntaxColorCommand; //user defined setting<br />
				}<br />
				<br />
			}


The solution that I've come up with is to use five separate foreach loops, setting the selectioncolor property for any keywords that are found within the loop. Problem is that it is really slow when it opens a new document (over 600 keywords in the xml file). Any advice on how to improve this code would be much appreciated.

Thanks for your help,
Chris Simpkins
GeneralRe: Regular Expression Code for Syntax Highlighting Pin
mav.northwind21-Jun-05 20:32
mav.northwind21-Jun-05 20:32 
GeneralRe: Regular Expression Code for Syntax Highlighting Pin
C_Simpkins21-Jun-05 20:40
C_Simpkins21-Jun-05 20:40 
Questionit make a dll but how? Pin
Sasuko21-Jun-05 13:42
Sasuko21-Jun-05 13:42 
AnswerRe: it make a dll but how? Pin
Christian Graus21-Jun-05 13:54
protectorChristian Graus21-Jun-05 13:54 
Generalchanging pixels color Pin
sami_bio@yahoo.com21-Jun-05 11:40
sami_bio@yahoo.com21-Jun-05 11:40 
GeneralRe: changing pixels color Pin
Christian Graus21-Jun-05 13:38
protectorChristian Graus21-Jun-05 13:38 
GeneralRe: changing pixels color Pin
sami_bio@yahoo.com21-Jun-05 18:33
sami_bio@yahoo.com21-Jun-05 18:33 
GeneralRe: changing pixels color Pin
Christian Graus21-Jun-05 18:38
protectorChristian Graus21-Jun-05 18:38 
GeneralMaking Menu Selections through Program Pin
Abhishek Karnik21-Jun-05 10:00
Abhishek Karnik21-Jun-05 10:00 
GeneralRe: Making Menu Selections through Program Pin
Rob Tomson21-Jun-05 10:44
Rob Tomson21-Jun-05 10:44 
GeneralRe: Making Menu Selections through Program Pin
Abhishek Karnik21-Jun-05 11:03
Abhishek Karnik21-Jun-05 11:03 
GeneralRe: Making Menu Selections through Program Pin
g00fyman21-Jun-05 17:41
g00fyman21-Jun-05 17:41 
GeneralRe: Making Menu Selections through Program Pin
Abhishek Karnik22-Jun-05 4:05
Abhishek Karnik22-Jun-05 4:05 
GeneralRe: Making Menu Selections through Program Pin
Dave Kreskowiak22-Jun-05 5:06
mveDave Kreskowiak22-Jun-05 5:06 
GeneralAuto-magicly put files in correct folders Pin
Tridith21-Jun-05 9:35
Tridith21-Jun-05 9:35 
GeneralRe: Auto-magicly put files in correct folders Pin
Luis Alonso Ramos21-Jun-05 16:29
Luis Alonso Ramos21-Jun-05 16:29 
GeneralSystem.Web.Mail for error reporting Pin
Rob Tomson21-Jun-05 9:16
Rob Tomson21-Jun-05 9:16 

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.