Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have been trying to find out how exactly you can embed classes/methods to get the following line to be processed:

 

Pages(1).Buttons(1).Add

 

How would a basic class look for this? Or would you have to create a Namespace?

 

I was trying to do something like:

 

Class Pages
    Class Buttons
         Property Add()
         End Property
    End Buttons
End Class

 

But I don't see a way or can't pass an index to a Class, can I? Basically, I want properties within properties or methods within methods..

 

Thanks in advance,

liquid8

  • *Gurus*
Posted

That's not "embedding" classes or methods. In this case, you would define your Pages class, and you would define a strongly-typed collection called ButtonCollection or something. Then you'd make a readonly property in the Pages class called Buttons, of type ButtonCollection.

 

Assuming the ButtonCollection had an Add method, you could then do,

 

Pages.Buttons.Add(blah)

 

For more help on creating a strongly-typed collection, see the CollectionBase class in the help. You'll have to inherit this.

 

If you wanted Pages itself to be a collection, you'd have to have to go two levels higher and write a PageCollection class, and have another class to host a property called Pages, of that type.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...