Link to home
Start Free TrialLog in
Avatar of MoonCalf
MoonCalf

asked on

Custom control - runtime or designtime?

Hi,

I've created a FolderTreeView control for an application we're working on at the moment.  It works great, but there's a problem.

It populates the treeview with my local drives/folders etc. at designtime.  Then, at runtime, the nodes are already there because they have become hard-coded into the initialize block.

I simply need to stop the code from executing when the control is in the IDE.

I've tried the following....

      if (!DesignMode)
      {
            CreateFolderList();
      }

where CreateFolderList is the initialization of the folder view, but it still does it when I drop the control onto a form.

Any ideas?

Thanks in advance,

John.
ASKER CERTIFIED SOLUTION
Avatar of Agarici
Agarici
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MoonCalf
MoonCalf

ASKER

Thanks for that Aqarici.

I already thought of taking that kind of approach and, if I can't get a method I'm happier with, then that's what I'll do (in which case I'll give you the points too.)

I do really want to find a method of doing what the code in the question should do.  It's something that I've come to expect from different languages now as it's a pretty straight-forward thing to do in most of them!

Anyway, thanks again for the help, but I'll leave this question open in the hope of finding a method of doing it the way I'd prefer.

John.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodelcomponentclassdesignmodetopic.asp

"The design mode indicator is stored in the ISite; therefore, if the Component does not have an ISite associated with it, this property is always false."

hth,
A.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the help everyone.

Agarici - I've accepted both comments as answers as they're both relevant.  The first comment is what I've ended up doing due to other issues, but the second accepted comment was definately more what I was asking for and I shall be using that in future.

Thanks again,

John.