public void Markup()
{
Regex rex = new Regex("<html>|</html>|<head.*?>|</head>|<body.*?>|</body>|<div.*?>|</div>|<span.*?>|</span>|<title.*?>|</title>|<style.*?>|</style>|<script.*?>|</script>|<link.*?/>|<meta.*?/>|<base.*?/>|<center.*?>|<center>|<a.*?>|</a>");
int selectionstart = richTextBox1.SelectionStart;
foreach (Match m in rex.Matches(richTextBox1.Text))
{
richTextBox1.Select(m.Index, m.Value.Length);
richTextBox1.SelectionColor = Color.Blue;
richTextBox1.Select(selectionstart, 0);
richTextBox1.SelectionColor = Color.Black;
}
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
int[] number = new int[] { 0 };
foreach (int num in number)
{
try
{
LockWindowUpdate(richTextBox1.Handle);//Stop flashing
Markup();
Elements();
TextMarkup();
FormsTabels();
Attributes();
Comments();
}
finally { LockWindowUpdate(IntPtr.Zero); }
}
}
As you can see I have quite a few more methods for highlighting which can really slow down my richTextBox so I tried running the methods in a foreach loops because I read it was able to process really fast but this did not help much, does any one else know of a way I could optimize this? Thanks.


Sign In
Create Account


Back to top









