ignoring events when loading form

N

Norvin Laudon

Hi,

I have a form with various controls which are wired to events when their
data, listindex, or whatever changes.

Simple question: As I'm loading the form (in the constructor), I need to set
the control's initial values without their events getting fired. It seems to
be a pretty common requirement. Any quick way of doing this? (short of using
a boolean flag!)

TIA,
Norvin
 
R

RCS

I don't know of any way, but how I've done this in the past is have a
class-level boolean called IsLoading, then inside all your events you have

if ( ! IsLoading )
{
}

Hope that helps...
 
M

Magnus Krisell

Why not wire the events after the initial values are set?
I believe Visual Studio uses this technique when it generates the
"InitializeComponent" method.

- Magnus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top