Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
GeneralRe: 1st chance exceptions in VS 2005 Pin
Ami Bar22-Jul-06 9:08
Ami Bar22-Jul-06 9:08 
GeneralRe: 1st chance exceptions in VS 2005 Pin
Nader Elshehabi22-Jul-06 10:52
Nader Elshehabi22-Jul-06 10:52 
Questioncompiler details Pin
waheed awan21-Jul-06 10:57
waheed awan21-Jul-06 10:57 
AnswerRe: compiler details Pin
Ed.Poore21-Jul-06 12:14
Ed.Poore21-Jul-06 12:14 
GeneralRe: compiler details Pin
Paul Conrad21-Jul-06 12:22
professionalPaul Conrad21-Jul-06 12:22 
AnswerRe: compiler details Pin
BoneSoft22-Jul-06 5:55
BoneSoft22-Jul-06 5:55 
QuestionRich text box Pin
waheed awan21-Jul-06 10:42
waheed awan21-Jul-06 10:42 
AnswerRe: Rich text box Pin
Ed.Poore21-Jul-06 12:26
Ed.Poore21-Jul-06 12:26 
Handle the keypress event, if it wasn't a space ignore it.
If it was a space then get the current cursor index, find the last space indicating the beginning of the word.  Set the selected index and length to cover this word, set the selected colour to the colour you want and finally reset the index to the original index so that you can continue typing.

E.g:
private void rtb_KeyPress(object sender, KeyPressEventArgs e)
{
	if (e.KeyChar == ' ')
	{
		this.rtb.SuspendLayout();
		Random rand = new Random();
		// Get previous word
                int startWordIndex = this.rtb.SelectionStart;
                while ((this.rtb.Text[--startWordIndex] != ' ') && (startWordIndex > 0))
                {
                }
                int endWordIndex = this.rtb.SelectionStart;
                // Check that the ranges are not negative
                if (startWordIndex < 0)
                    startWordIndex = 0;
                // Set the selection range
                this.rtb.SelectionStart = startWordIndex;
                this.rtb.SelectionLength = endWordIndex - startWordIndex;
                this.rtb.SelectionColor = Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255));
                this.rtb.SelectionStart = endWordIndex;
                this.rtb.SelectionLength = 0;
                // Resume layout
                this.rtb.ResumeLayout();
	}
}
Hope this helps



The Welsh will always support two teams: The Welsh, and anyone playing England Smile | :)
QuestionWhy the following condition is never met? Pin
xkx3221-Jul-06 10:06
xkx3221-Jul-06 10:06 
AnswerRe: Why the following condition is never met? Pin
Dustin Metzgar21-Jul-06 10:38
Dustin Metzgar21-Jul-06 10:38 
GeneralRe: Why the following condition is never met? Pin
xkx3221-Jul-06 10:52
xkx3221-Jul-06 10:52 
Questionhow to multicast serialized objects through UDPClient socket Pin
duaaali21-Jul-06 9:11
duaaali21-Jul-06 9:11 
Questionfrog puzzle Pin
divaa21-Jul-06 8:23
divaa21-Jul-06 8:23 
AnswerRe: frog puzzle Pin
Josh Smith21-Jul-06 8:47
Josh Smith21-Jul-06 8:47 
GeneralRe: frog puzzle Pin
Paul Conrad21-Jul-06 9:26
professionalPaul Conrad21-Jul-06 9:26 
GeneralRe: frog puzzle Pin
Dan Neely21-Jul-06 9:32
Dan Neely21-Jul-06 9:32 
GeneralRe: frog puzzle Pin
Paul Conrad21-Jul-06 9:35
professionalPaul Conrad21-Jul-06 9:35 
AnswerRe: frog puzzle Pin
Dan Neely21-Jul-06 9:12
Dan Neely21-Jul-06 9:12 
GeneralRe: frog puzzle Pin
Paul Conrad21-Jul-06 9:29
professionalPaul Conrad21-Jul-06 9:29 
GeneralRe: frog puzzle Pin
Dustin Metzgar21-Jul-06 11:06
Dustin Metzgar21-Jul-06 11:06 
AnswerRe: frog puzzle Pin
Paul Conrad21-Jul-06 9:31
professionalPaul Conrad21-Jul-06 9:31 
AnswerRe: frog puzzle Pin
Professor Sharada Ulhas21-Jul-06 11:09
Professor Sharada Ulhas21-Jul-06 11:09 
GeneralRe: frog puzzle Pin
Paul Conrad21-Jul-06 11:17
professionalPaul Conrad21-Jul-06 11:17 
GeneralRe: frog puzzle Pin
Judah Gabriel Himango21-Jul-06 12:00
sponsorJudah Gabriel Himango21-Jul-06 12:00 
QuestionDynamic Page Creation? Pin
OMalleyW21-Jul-06 8:20
OMalleyW21-Jul-06 8:20 

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.