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 / .NET Framework / CLR / November 2006

Tip: Looking for answers? Try searching our database.

ToolboxItemFilter - can't get it to work!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AJ - 30 Oct 2006 23:34 GMT
Why oh why can't I get the following working :-) (Studio2005)

I'm trying to use ToolboxItemFilter to restrict what controls are
available when desiging a custom control. So I've a trivial example
application:

 [ToolboxItemFilter("Test",ToolboxItemFilterType.Require)]
 public class MyDesigner : DocumentDesigner { }

 [Designer(typeof(MyDesigner),typeof(IRootDesigner))]
 [ToolboxItemFilter("Test")]
 public class MyBase : Panel { }

 [ToolboxItemFilter( "Test"  )]
 public class SomeControl : Panel { }

Then add a 'UserControl' to the project; change its base class to be
MyBase, re-compile, and edit in the IDE.

There are NO items available in the toolbox.

Comment out the line
 [ToolboxItemFilter("Test",ToolboxItemFilterType.Require)]
and all the control appear again.

So, it's failing to notice the Filter attribute on the MyBase and
SomeControl items....

Any ideas? I can't see what I'm doing differently to the sample
application (shape designer) on MSDN, really..
Ben Voigt - 31 Oct 2006 16:02 GMT
> Why oh why can't I get the following working :-) (Studio2005)
>
[quoted text clipped - 11 lines]
>  [ToolboxItemFilter( "Test"  )]
>  public class SomeControl : Panel { }

[snip]
> Any ideas? I can't see what I'm doing differently to the sample
> application (shape designer) on MSDN, really..

The sample uses ToolboxItemFilterType.Custom.

From the docs, it looks as if ToolboxItemFilterType.Custom permits a
designer to restrict which toolbox items appear when that designer is
active, while ToolboxItemFilterType.Require permits a component to restrict
itself to certain designers.  Nowhere is putting
ToolboxItemFilterType.Require on a designer discussed.
AJ - 31 Oct 2006 16:52 GMT
> > Why oh why can't I get the following working :-) (Studio2005)
> >
[quoted text clipped - 23 lines]
> itself to certain designers.  Nowhere is putting
> ToolboxItemFilterType.Require on a designer discussed.

The sample at
http://windowsforms.net/articles/shapedesigner.aspx
uses the .require on both the designer and the component...

I can get .custom to work. (You then need to implement the
IToolboxUser.GetToolSupported method), but the simple .require/.prevent
etc. enums are supposed to be simpler.

It's clearly doing something, since removing the .require from the
MyDesigner means all the controls appear again. It just doesn't seem to
be picking them up from the controls...
AJ - 03 Nov 2006 11:43 GMT
Further to the following, I think its a bug/feature of the IDE....

Add/remove a ToolboxItemFilter attribute to a designer, re-build the
project, and the change gets reflected immediately in the IDE.

Add/remove the attribute to a control/component, re-build... The change
doesn't get reflected until the IDE is restarted.

(Presumably, more specifically, until the toolbar is re-loaded, but I
can't see a simple way of doing that..)

I'd consider this a bug in the IDE.

> Why oh why can't I get the following working :-) (Studio2005)
>
[quoted text clipped - 26 lines]
> Any ideas? I can't see what I'm doing differently to the sample
> application (shape designer) on MSDN, really..
Ben Voigt - 04 Nov 2006 00:01 GMT
> Further to the following, I think its a bug/feature of the IDE....
>
[quoted text clipped - 3 lines]
> Add/remove the attribute to a control/component, re-build... The change
> doesn't get reflected until the IDE is restarted.

I believe you only have to close all Forms Designers, not the entire IDE,
but I could be wrong.

> (Presumably, more specifically, until the toolbar is re-loaded, but I
> can't see a simple way of doing that..)
[quoted text clipped - 31 lines]
>> Any ideas? I can't see what I'm doing differently to the sample
>> application (shape designer) on MSDN, really..
AJ - 06 Nov 2006 09:01 GMT
> > Further to the following, I think its a bug/feature of the IDE....
> >
[quoted text clipped - 6 lines]
> I believe you only have to close all Forms Designers, not the entire IDE,
> but I could be wrong.

I'm pretty sure I tried that, and it doesn't work.

In any case it's inconsistent.... the attribute on the designer object
is reflected immediately (without needing to close anything - it
automatically refreshes the toolbars). The attribute on the control
class needs a restart.

> > (Presumably, more specifically, until the toolbar is re-loaded, but I
> > can't see a simple way of doing that..)
[quoted text clipped - 25 lines]
> >>   [ToolboxItemFilter("Test",ToolboxItemFilterType.Require)]
> >> and all the control appear again.

Rate this thread:







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.