I created a DLL file within some keywords, like this: "#include ", "#define ", "int ", "return "...
It's C keywords, but I'm talking about C#.
I will show you my full code. Sorry, I don't know exactly where is the problem.
Here is my code:
RichTextBox rtb = new RichTextBox();
object[] total;
private void CallingFirst()
{
kwlib.kwlib kw = new kwlib.kwlib();
string[] datatypes = kw.DataTypes;
string[] statements = kw.Statements;
string[] declaration = kw.Declaration;
string[] libReference = kw.LibReference;
string[] functionRef = kw.FunctionRef;
object[] o = new object[]
{ declaration, libReference, datatypes, statements, functionRef };
this.total = o;
}
private void SettingColor(string[] temp, int i)
{
int index = WritingRTB.SelectionStart;
Color colour = WritingRTB.SelectionColor;
int start = WritingRTB.Text.IndexOf(temp[i]);
WritingRTB.Select(start, temp[i].Length);
if ((temp != total[0]) && (temp != total[1]))
{
rtb.ForeColor = Color.Blue;
}
else
{
rtb.ForeColor = Color.RoyalBlue;
}
this.FormatingTB();
WritingRTB.Focus();
WritingRTB.SelectionStart = start;
WritingRTB.Paste();
WritingRTB.SelectionStart = index;
WritingRTB.SelectionColor = colour;
}
private void FormatingTB()
{
rtb.Font = new System.Drawing.Font("Times New Roman", 12);
rtb.Text = WritingRTB.SelectedText;
WritingRTB.SelectedText = String.Empty;
rtb.SelectAll();
rtb.Copy();
}
private void CheckingKeywords()
{
object[] ob = this.total;
foreach (string[] temp in ob)
{
for (int i = 0; i < temp.Length; i++)
{
if (WritingRTB.Text.Contains(temp[i]))
{
this.SettingColor(temp, i);
}
}
}
}
datatypes, statements, declaration, libReference, functionRef are array strings which contain keywords.
Some problems I had detected:
1/. When RichTextBox was shown, I typed 2 lines.
Line 1 was: #include "stdio.h" <<== This line was colored true.
Line 2 was: #include "conio.h" <<== conio.h was colored RoyalBlue, but it's still Black for #include
Why?
2/. I can't type text with high speed. Because the data will be lost.
When I tried doing, the cursor was appeared at "all already keywords" and deleted it.
3/. When I typed "int ", it was blue. That's ok. After that, I press Backspace to delete it. "in" was still blue.
Data was not updated. Why?
Can you tell me why and how to fix it? I'm using C# Winform with .Net 4.5
Sorry for my very long question.
Thank you!