all groups > dotnet clr > october 2006 >
You're in the

dotnet clr

group:

ToolboxItemFilter - can't get it to work!


ToolboxItemFilter - can't get it to work! AJ
10/30/2006 10:34:45 PM
dotnet clr:
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
Re: ToolboxItemFilter - can't get it to work! Ben Voigt
10/31/2006 9:02:11 AM

[quoted text, click to view]

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.

Re: ToolboxItemFilter - can't get it to work! AJ
10/31/2006 3:52:22 PM
In article <OdvlM2P$GHA.4388@TK2MSFTNGP02.phx.gbl>, rbv@nospam.nospam
says...
[quoted text, click to view]

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...
BUG in the IDE! Re: ToolboxItemFilter - can't get it to work! AJ
11/3/2006 10:43:06 AM
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.


In article <MPG.1fb08e596619771e98969b@news.zen.co.uk>,
noone@nowhere.com says...
[quoted text, click to view]
Re: BUG in the IDE! Re: ToolboxItemFilter - can't get it to work! Ben Voigt
11/3/2006 5:01:14 PM

[quoted text, click to view]

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

[quoted text, click to view]

Re: BUG in the IDE! Re: ToolboxItemFilter - can't get it to work! AJ
11/6/2006 12:00:00 AM
In article <#Hx71v5$GHA.5060@TK2MSFTNGP02.phx.gbl>, rbv@nospam.nospam
says...
[quoted text, click to view]

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.


[quoted text, click to view]
AddThis Social Bookmark Button