Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / October 2006

Tip: Looking for answers? Try searching our database.

Can't duplicate what VS is doing with TabControl

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Palor - 04 Oct 2006 23:39 GMT
I'm trying to write a control, and it would be greatly if it worked
similar to tab control.

The basic thing I can't duplicate is as follows:

In the property window for TabControl, you can add tabs to the TabPages
collection, after you have done that, if you look at the designer code,
it doesn't add the tabs to the TabPages, it adds them to the
ControlCollection (tabControlControls.Add(newTab)).

I'm guessing there is some attribute that is telling VS to do this, but
I can't find it.

Thanks in advance for any help,
Brian
Mick Doherty - 05 Oct 2006 14:49 GMT
Public Readonly Property SomeCollection() As ControlCollection
   Get()
       Return MyBase.Controls
   End Get
End Property

Take a look at the PanelManager source on my site:
http://www.dotnetrix.co.uk/custom.html

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

> I'm trying to write a control, and it would be greatly if it worked
> similar to tab control.
[quoted text clipped - 11 lines]
> Thanks in advance for any help,
> Brian
Palor - 06 Oct 2006 03:03 GMT
Thank you,
That has taken me one step closer.  As far as I can tell, only a single
step remians.

(Continuing on with my previous exmpale...)
That definantly solved my problem, now the designer simply adds the
'tabs' to the control collection, but now when, in the designer, I
click the elipse button to open up the collection editor, it assumes
that I am adding Controls to the collection, not TabPages.  Is there a
simple fix for this, or does this make everything a lot more
complicated?

Brian

> Public Readonly Property SomeCollection() As ControlCollection
>     Get()
[quoted text clipped - 24 lines]
> > Thanks in advance for any help,
> > Brian
Mick Doherty - 06 Oct 2006 15:37 GMT
That's why I pointed you to the PanelManager source which very likely
implements all the methods that you may need.

You just need a custom CollectionEditor, which you associate to the property
via the EditorAttribute. You will need to add a reference to
System.Design.dll in order to use the CollectionEditor.

Imports System.ComponentModel
Imports System.Drawing.Design
Imports System.ComponentModel.Design

Public Class MyControl
...
<Editor(GetType(ButtonCollectionEditor), GetType(UITypeEditor))> _
Public ReadOnly Property Buttons() As ControlCollection
   Get
       Return MyBase.Controls
   End Get
End Property

Private Class ButtonCollectionEditor
   Inherits CollectionEditor

   Public Sub New(ByVal type As Type)
       MyBase.New(type)
   End Sub

   Protected Overrides Function CreateCollectionItemType() As System.Type
       Return GetType(Button)
   End Function

End Class
...
End Class

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

> Thank you,
> That has taken me one step closer.  As far as I can tell, only a single
[quoted text clipped - 38 lines]
>> > Thanks in advance for any help,
>> > Brian

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.