Click here to Skip to main content
15,909,091 members
Home / Discussions / C#
   

C#

 
GeneralRe: Correct way to reset the modem Pin
Serge Lobko-Lobanovsky5-Aug-04 3:17
Serge Lobko-Lobanovsky5-Aug-04 3:17 
GeneralRe: Correct way to reset the modem Pin
Heath Stewart5-Aug-04 3:24
protectorHeath Stewart5-Aug-04 3:24 
GeneralRe: Correct way to reset the modem Pin
Squeaker5-Aug-04 7:24
Squeaker5-Aug-04 7:24 
Questionis it possible to forcE thumbnail view in open dialog? Pin
misterbear5-Aug-04 1:33
misterbear5-Aug-04 1:33 
QuestionWhich richTextBox Event to use ? Pin
evdoxos5-Aug-04 1:16
evdoxos5-Aug-04 1:16 
AnswerRe: Which richTextBox Event to use ? Pin
Heath Stewart5-Aug-04 2:55
protectorHeath Stewart5-Aug-04 2:55 
GeneralRe: Which richTextBox Event to use ? Pin
evdoxos5-Aug-04 3:09
evdoxos5-Aug-04 3:09 
GeneralRe: Which richTextBox Event to use ? Pin
Heath Stewart5-Aug-04 3:14
protectorHeath Stewart5-Aug-04 3:14 
That code would load the processor tremendously. The TextChanged event is fired very often and attaching and detaching event handlers is expensive.

Instead of doing that, just use a state variable. In your handler (and why are you using the same handler which would make changes to the text, thus calling the handler again in a loop), just check if a state variable (herhaps a bool) is set or unset (true and false, respectively). When you change the color, set the state variable, when you're done making changes, reset it. The handler would check the state of this variable and conditionally execute.

State variables are used everywhere in some form or fashion, and would be best to use here.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Which richTextBox Event to use ? Pin
evdoxos5-Aug-04 3:24
evdoxos5-Aug-04 3:24 
QuestionProbably Reflection... but how? Pin
matthias s.5-Aug-04 1:05
matthias s.5-Aug-04 1:05 
AnswerRe: Probably Reflection... but how? Pin
Heath Stewart5-Aug-04 2:47
protectorHeath Stewart5-Aug-04 2:47 
GeneralRe: Probably Reflection... but how? Pin
matthias s.5-Aug-04 3:26
matthias s.5-Aug-04 3:26 
GeneralRe: Probably Reflection... but how? Pin
Heath Stewart5-Aug-04 3:35
protectorHeath Stewart5-Aug-04 3:35 
Generalget opened folder in Outlook Pin
Stephan Wright5-Aug-04 0:36
Stephan Wright5-Aug-04 0:36 
GeneralRe: get opened folder in Outlook Pin
Michael P Butler5-Aug-04 4:09
Michael P Butler5-Aug-04 4:09 
GeneralRe: get opened folder in Outlook Pin
Stephan Wright5-Aug-04 22:46
Stephan Wright5-Aug-04 22:46 
GeneralRe: get opened folder in Outlook Pin
Michael P Butler5-Aug-04 22:51
Michael P Butler5-Aug-04 22:51 
GeneralRe: get opened folder in Outlook Pin
Stephan Wright5-Aug-04 23:01
Stephan Wright5-Aug-04 23:01 
GeneralRe: get opened folder in Outlook Pin
Michael P Butler5-Aug-04 23:17
Michael P Butler5-Aug-04 23:17 
Generaldisable poweroff function Pin
JockerSoft4-Aug-04 22:57
JockerSoft4-Aug-04 22:57 
GeneralRe: disable poweroff function Pin
leppie5-Aug-04 0:45
leppie5-Aug-04 0:45 
GeneralRe: disable poweroff function Pin
Heath Stewart5-Aug-04 1:46
protectorHeath Stewart5-Aug-04 1:46 
GeneralRe: disable poweroff function Pin
Heath Stewart5-Aug-04 2:24
protectorHeath Stewart5-Aug-04 2:24 
GeneralRe: disable poweroff function Pin
Dave Kreskowiak5-Aug-04 8:10
mveDave Kreskowiak5-Aug-04 8:10 
GeneralRe: disable poweroff function Pin
JockerSoft5-Aug-04 22:25
JockerSoft5-Aug-04 22:25 

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.