hi.
i am really stock at this i have tried a lot of diffrent sollutions on my problem but non of the worked as i wanted them to.
i dont have any code snippet for it because it dident work.
i dont have any code snippet for it because it dident work.
so if you can help med i will really be tank full
sorry for bad eng
theLizardPosted Feb 20, 2014, 7:08 PM
{
string word;
FontStyle fs;
if (start > -1 && end > start && e.KeyData == Keys.Space)
{
word = richTextBox1.Text.Substring(start+1, end - (start+1));
if (word.ToUpper().Contains("X"))
{
fs = FontStyle.Bold;
richTextBox1.Select(start, end);
richTextBox1.SelectionColor = Color.Red;
richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, fs);
richTextBox1.Select(end + 1, 0);
}
start = end;
fs = FontStyle.Regular;
richTextBox1.SelectionColor = Color.Black;
richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, fs);
}
}
private void richText1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == ' ')
{
if (start == -1)
start = richTextBox1.TextLength;
if (start >= 0 && richTextBox1.TextLength > start)
end = richTextBox1.TextLength;
}
}
This is just an example of how you can do it but you have a lot of work to do to get it to work for ALL conditions, for example you may need to track every single word position that contains an X in it, this could be done with an array of Points eg Point p = new Point(x, y);
x being the start of the word, y being the end but then you would need to know about paragraphs, line number etc .....
kevin bredahlPosted Feb 20, 2014, 9:08 AM
KalaiPosted Feb 20, 2014, 5:38 AM
kevin bredahlPosted Feb 20, 2014, 3:16 AM
KalaiPosted Feb 20, 2014, 1:54 AM
RichTextBox Richtxt = new RichTextBox();
Richtxt.Width = 100;
Richtxt.Height = 50;
Richtxt.ForeColor = Color.Green;
Richtxt.Text = "RichTextBox";
Richtxt.Name = "RichTextBox";
Controls.Add(Richtxt);