You really must be more precize if you expect help from others. Above you
wrote "it doesn't recognize it". Now you write "it doesn't show". I'm gonna
assume the latter. Or, "it doesn't show" via intellisense? I don't know.
Seems to be one of the problems MSFT reintroduced with the reintroductionof
the fatal Form "default instances" they got rid of in VB 2002/2003. Was
meant to make it easier for beginners. Yeah, sure - but it doesn't. I can't
tell you how much I "dislike" these default instances.
I hardly know where to start..., well, the first thing you have to know is
that VB does several things under the hood. This makes it sometimes
complicated to understand how things work. One invisible class it compiles
into your project is called 'MyProject' under the 'My' namespace. For
example, the full name is "WinApplication1.My.MyProject". It's a special
class that we call a Module in VB syntax. In addition, another invisible
class is created. It's called 'MyForms'. It is as a nested class inside
class MyProject. It has one property per Form in the project. Each
property's name is the same name as the Form's class name. Each property
returns an instance of a Form of the corresponding Form type. The module
MyProject has a property called Forms. It is of type MyForms.
Whenever you write:
FormClassName.Member
the VB compiler behaves very special: 'FormClassName' is resolved to
Forms.FormClassName. As 'MyProject' is a Module, the Forms property is
actually a shared member. Consequently, there can be exactly one default
instance of each Form in your project.
So far, so bad. Back to your project. If you write
'Explorer1.AddFolder2Database', you are accessing the default instance of
the Form. Hovering the mouse above 'Explorer1', the IDE is incorrectly
showing "Class Explorer1". Well, it's also a class, but not in this context.
If it was resolved to the class name, you would only be able to access the
shared members. In fact you are able to write
Explorer1.Show
How can this be possible as Explorer1 is a class but Show is an _instance_
member? Actually Explorer1 is a property, but MSFT doesn't want us to know
this and prefers to hide the details.
(Hopefully) coming to the solution: How did you create an instance of Form
Explorer1 that you see on the screen? If you add folders (in
AddFolder2Database) and they don't appear on your visible Form, I guess you
didn't show the default instance but are you adding the items to the default
instance.
BTW, why do you call TreeView.Refresh? (I do have a reason for this question
but will wait for your answer.)
If you don't want to be confused by this intransparent and badly designed
model (namely the whole My.Crap), just add
_mytype="empty"
to the compile constants in your project's properties. I've created a
project template for this. But, don't be surprised if you will have
additional 1001 questions after that. ;-) (No, it would not solve your
problem! - but mine)
See also:
http://msdn.microsoft.com/en-us/library/ms233781.aspx
(anyway, it does not really make things more comprehensive)
Armin