473,624 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MarqueeControl: MSDN Walkthrough question

Hello,

I have been going through the MSDN Walkthrough: Creating a Windows
Forms Control That Takes Advantage of Visual Studio Design-Time
Features.

Everything was going fine and I was able to create and compile the
MarqueeControlL ibrary project. And I think I even understood most of
it.

Anyway, at the end of the Walkthrough, they say the next step is to
test the custom control in the designer. In that section of the
Walkthrough, I can get past step 1, but then have problems on step 2.
I create a new usercontrol, DemoMarqueeCont rol, which derives from the
MarqueeControl. However, when I open this up in Design View and try to
add either the MarqueeText or MarqueeBorder controls to it, the Toolbox
is completely empty. It gives me the message, "There are no usable
controls..." If I right-click and select "Show All", all the controls
show up, but they are disabled.

So I'm wondering if there is a problem with the Walkthrough or if I am
making a mistake somewhere. I'd really love to understand what is
going on and continue learning about custom controls.

Why is the Toolbox empty when I have a derived Usercontrol in Design
View??

Nov 25 '06 #1
7 1499
Hi,

Is this the walkthrough to which you are referring?

http://msdn2.microsoft.com/en-us/lib...wb(VS.80).aspx

It sounds to me like you're viewing the component designer, not the control
designer.

Does your project build?

Could you verify whether DemoMarqueeCont rol is actually a descendant of
System.Windows. Forms.UserContr ol and whether its designer has resize handles
just like that of the Form designer?

FYI, to add an inherited UserControl to your project you should choose
"Inherited User Control" instead of just "User Control" from the "Add New
Item" dialog, and choose the ancestor of the new control from a list
provided by Visual Studio. The list is populated with all classes in the
current project and referenced assemblies that inherit from UserControl.

--
Dave Sexton

"John D'oh" <cb*******@gmai l.comwrote in message
news:11******** **************@ j72g2000cwa.goo glegroups.com.. .
Hello,

I have been going through the MSDN Walkthrough: Creating a Windows
Forms Control That Takes Advantage of Visual Studio Design-Time
Features.

Everything was going fine and I was able to create and compile the
MarqueeControlL ibrary project. And I think I even understood most of
it.

Anyway, at the end of the Walkthrough, they say the next step is to
test the custom control in the designer. In that section of the
Walkthrough, I can get past step 1, but then have problems on step 2.
I create a new usercontrol, DemoMarqueeCont rol, which derives from the
MarqueeControl. However, when I open this up in Design View and try to
add either the MarqueeText or MarqueeBorder controls to it, the Toolbox
is completely empty. It gives me the message, "There are no usable
controls..." If I right-click and select "Show All", all the controls
show up, but they are disabled.

So I'm wondering if there is a problem with the Walkthrough or if I am
making a mistake somewhere. I'd really love to understand what is
going on and continue learning about custom controls.

Why is the Toolbox empty when I have a derived Usercontrol in Design
View??

Nov 26 '06 #2
Is this the walkthrough to which you are referring?
http://msdn2.microsoft.com/en-us/lib...wb(VS.80).aspx
Yeah, that's the one.
Does your project build?
Yes, the project builds.
Could you verify whether DemoMarqueeCont rol is actually a descendant of
System.Windows. Forms.UserContr ol and whether its designer has resize handles
just like that of the Form designer?
It is a descendant of MarqueeControl, not UserControl. And it does
have resize handles in the designer. I can resize the
DemoMarqueeCont rol, I just can't add anything to it because the Toolbox
is empty.
Here's the code from DemoMarqueeCont rol.cs after I add it to the
project:
namespace MarqueeControlT est
{
public partial class DemoMarqueeCont rol : MarqueeControl
{
public DemoMarqueeCont rol()
{
InitializeCompo nent();
}
}
}
FYI, to add an inherited UserControl to your project you should choose
"Inherited User Control" instead of just "User Control" from the "Add New
Item" dialog, and choose the ancestor of the new control from a list
provided by Visual Studio. The list is populated with all classes in the
current project and referenced assemblies that inherit from UserControl.
Thanks for the tip. I used that method to add a DemoMarqueeCont rol2 to
the MarqueeControlT est project and the result was the same. I can
resize the control in the designer, but the Toolbox is empty, so I
can't add a MarqueeBorder or MarqueeText control to it.

It seems like the MarqueeControl isn't acting like a container which
can host other controls. If I go to the Form1 designer (where things
show up in the Toolbox), I can add a MarqueeControl. Then if I try to
add a MarqueeBorder (or MarqueeText) control in it, the control is just
placed on top of the MarqueeControl. It's added to Form1's
controlCollecti on, not MarqueeControl' s controlCollecti on.

If I go to MarqueeControl' s design view in the ControlLibrary project,
I can add a MarqueeText or MarqueeBorder to it without any problems.

Nov 26 '06 #3
Hi,

<snip>
>Could you verify whether DemoMarqueeCont rol is actually a descendant of
System.Windows .Forms.UserCont rol and whether its designer has resize
handles
just like that of the Form designer?
It is a descendant of MarqueeControl, not UserControl. And it does
have resize handles in the designer.
If MarqueeControl derives from UserControl and DemoMarqueeCont rol derives
from MarqueeControl, then DemoMarqueeCont rol is a descendant of UserControl
as well. Since resize handles appear I'll just assume that it is a
UserControl and you are viewing the control designer, not the component
designer, as I originally suspected.

<snip>
Thanks for the tip. I used that method to add a DemoMarqueeCont rol2 to
the MarqueeControlT est project and the result was the same. I can
resize the control in the designer, but the Toolbox is empty, so I
can't add a MarqueeBorder or MarqueeText control to it.
What happens if you right-mouse click the empty space in the Toolbox and
select "Reset Toolbox"?
It seems like the MarqueeControl isn't acting like a container which
can host other controls. If I go to the Form1 designer (where things
show up in the Toolbox), I can add a MarqueeControl. Then if I try to
add a MarqueeBorder (or MarqueeText) control in it, the control is just
placed on top of the MarqueeControl. It's added to Form1's
controlCollecti on, not MarqueeControl' s controlCollecti on.
That is the expected behavior for UserControls when added to another
designer. UserControls provide an encapsulated GUI much like other
controls, but with their own design-time interface. For example, you can't
drag and drop controls into a Label or PictureBox either.

If you want the behavior that you have expressed here for your control then
you should derive from ContainerContro l, for instance, but then you won't
have a control designer; only a component designer will be provided by
Visual Studio.
If I go to MarqueeControl' s design view in the ControlLibrary project,
I can add a MarqueeText or MarqueeBorder to it without any problems.
Well, at least that is working for you :)

--
Dave Sexton
Nov 26 '06 #4
Hey,
If MarqueeControl derives from UserControl and DemoMarqueeCont rol derives
from MarqueeControl, then DemoMarqueeCont rol is a descendant of UserControl
as well. Since resize handles appear I'll just assume that it is a
UserControl and you are viewing the control designer, not the component
designer, as I originally suspected.
Sorry, maybe I'm confused on the difference between the component
designer and control designer. But what you said about
DemoMarqueeCont rol being a descendant of UserControl is correct and it
is how I understand it.

When I double-click on DemoMarqueeCont rol.cs in the Solution Explorer,
it opens up a designer. I guess I don't know the name of that
designer.

By the way, I have no idea what I did, but things are now working. I
see only MarqueeText & MarqueeBorder in the Toolbox when in the
designer for DemoMarqueeCont rol (and DemoMarqueeCont rol2). I even
created a DemoMarqueeCont rol3 and it works as well.

Aargh, now I don't think I'll ever be able to figure out what the
problem was. If you have any ideas, I'd love to know what I initially
did wrong.

By the way, I did a Reset Toolbox and that didn't change anything.
That is the expected behavior for UserControls when added to another
designer. UserControls provide an encapsulated GUI much like other
controls, but with their own design-time interface. For example, you can't
drag and drop controls into a Label or PictureBox either.
I guess this is the part I don't understand. As far as I understood,
MarqueeControl is an empty UserControl. I thought it's purpose was to
hold MarqueeText & MarqueeBorder controls (as well as any other
controls) and provide some methods (Start() & Stop() ) to control the
animation. So I assumed that if I opened MarqueeControl or
DemoMarqueeCont rol in a designer, I would be able to add other controls
in it. Therefore, MarqueeControl or DemoMarqueeCont rol would act like
a Panel and be the parent of the controls I added. Am I understanding
things correctly?

And since you've been so helpful, I'm hoping you can answer 1 more
question for me. What is the code that tells the Toolbox to show
MarqueeText & MarqueeBorder when in the designer for
DemoMarqueeCont rol.

Is it these lines that were put in MarqueeControlR ootDesigner.cs?
[ToolboxItemFilt er("MarqueeCont rolLibrary.Marq ueeBorder",
ToolboxItemFilt erType.Require)]
[ToolboxItemFilt er("MarqueeCont rolLibrary.Marq ueeText",
ToolboxItemFilt erType.Require)]

Thanks again.

Nov 26 '06 #5
Hi,

<snip>
When I double-click on DemoMarqueeCont rol.cs in the Solution Explorer,
it opens up a designer. I guess I don't know the name of that
designer.
Since it has resize handles, as you've mentioned already, you will be
designing the control. If you add a component to your designer from the
Toolbox (e.g., BackgroundWorke r or FileSystemWatch er) then you'll see the
component tray appear at the bottom of the control designer. The component
designer is basically a full-screen component tray. There are no resize
handles and no "visual" way to design the graphical interface of the
component. Therefore, you are limited to only being able to add components
from the Toolbox, but not controls that provide a graphical interface. If
you want to see the component designer, create a class that derives from
System.Componen tModel.Componen t instead of UserControl.
By the way, I have no idea what I did, but things are now working. I
see only MarqueeText & MarqueeBorder in the Toolbox when in the
designer for DemoMarqueeCont rol (and DemoMarqueeCont rol2). I even
created a DemoMarqueeCont rol3 and it works as well.
:)
Aargh, now I don't think I'll ever be able to figure out what the
problem was. If you have any ideas, I'd love to know what I initially
did wrong.
I'm still not sure what went wrong.
>That is the expected behavior for UserControls when added to another
designer. UserControls provide an encapsulated GUI much like other
controls, but with their own design-time interface. For example, you
can't
drag and drop controls into a Label or PictureBox either.

I guess this is the part I don't understand. As far as I understood,
MarqueeControl is an empty UserControl. I thought it's purpose was to
hold MarqueeText & MarqueeBorder controls (as well as any other
controls) and provide some methods (Start() & Stop() ) to control the
animation. So I assumed that if I opened MarqueeControl or
DemoMarqueeCont rol in a designer, I would be able to add other controls
in it.
Within its own designer or that of its derived controls, yes.
Therefore, MarqueeControl or DemoMarqueeCont rol would act like
a Panel and be the parent of the controls I added. Am I understanding
things correctly?
No. When a UserControl is added to a Form's designer, for example, it
shouldn't behave like a Panel. The idea is that a UserControl encapsulates,
usually compositing, a graphical interface. When you add the UserControl to
a Form's designer you should think of it as a standard control such as a
TextBox or Label. If you want a control that behaves as Panel does, then
you must derive from Panel or ContainerContro l, for example, but not
UserControl (an alternative to inheritance is to use the appropriate
designer, which I believe is ParentControlDe signer, IIRC).
And since you've been so helpful, I'm hoping you can answer 1 more
question for me. What is the code that tells the Toolbox to show
MarqueeText & MarqueeBorder when in the designer for
DemoMarqueeCont rol.

Is it these lines that were put in MarqueeControlR ootDesigner.cs?
[ToolboxItemFilt er("MarqueeCont rolLibrary.Marq ueeBorder",
ToolboxItemFilt erType.Require)]
[ToolboxItemFilt er("MarqueeCont rolLibrary.Marq ueeText",
ToolboxItemFilt erType.Require)]
Actually, I believe that those two lines are the reason that every item is
disabled except for MarqueeBorder and MarqueeText :)

Normally, you don't add any ToolboxItemFilt erAttributes to your custom
controls or designers so that all classes that derive from Control (TextBox,
Label and UserControls, for example) are available in the Toolbox.

So it seems that the tutorial did not intend for MarqueeControl and its
derived classes to contain just any Control, but only the two listed above.
If you change "Require" to "Allow", or just remove both of the attributes
from MarqueeControlR ootDesigner altogether, then you should be able to add
all Controls to the MarqueeControl' s designer from the Toolbox and not just
the two listed above. If not, then try removing the ToolboxItemFilt er
attributes from the MarqueeBorder and MarqueeText controls as well. I'm not
sure of the exact behavior of ToolboxItemFilt erAttribute since I haven't
used it myself.

--
Dave Sexton
Nov 26 '06 #6
Hi,
Aargh, now I don't think I'll ever be able to figure out what the
problem was. If you have any ideas, I'd love to know what I initially
did wrong.
I'm still not sure what went wrong.
Now that I look back on it, I'm wondering if your tip about "Reset
Toolbox" is what finally got things working.
If you add a component to your designer from the
Toolbox (e.g., BackgroundWorke r or FileSystemWatch er) then you'll see the
component tray appear at the bottom of the control designer. The component
designer is basically a full-screen component tray. There are no resize
handles and no "visual" way to design the graphical interface of the
component. Therefore, you are limited to only being able to add components
from the Toolbox, but not controls that provide a graphical interface. If
you want to see the component designer, create a class that derives from
System.Componen tModel.Componen t instead of UserControl.
OK, I understand and know what you're talking about. I've just always
called both of them the designers and never distinguished the two.
Thanks for clearing that up.
Therefore, MarqueeControl or DemoMarqueeCont rol would act like
a Panel and be the parent of the controls I added. Am I understanding
things correctly?No. When a UserControl is added to a Form's designer, for example, it
shouldn't behave like a Panel. The idea is that a UserControl encapsulates,
usually compositing, a graphical interface. When you add the UserControl to
a Form's designer you should think of it as a standard control such as a
TextBox or Label. If you want a control that behaves as Panel does, then
you must derive from Panel or ContainerContro l, for example, but not
UserControl (an alternative to inheritance is to use the appropriate
designer, which I believe is ParentControlDe signer, IIRC).
OK, I understand this now and it makes perfect sense.
So it seems that the tutorial did not intend for MarqueeControl and its
derived classes to contain just any Control, but only the two listed above.
If you change "Require" to "Allow", or just remove both of the attributes
from MarqueeControlR ootDesigner altogether, then you should be able to add
all Controls to the MarqueeControl' s designer from the Toolbox and not just
the two listed above. If not, then try removing the ToolboxItemFilt er
attributes from the MarqueeBorder and MarqueeText controls as well. I'm not
sure of the exact behavior of ToolboxItemFilt erAttribute since I haven't
used it myself.
I commented out the two lines (and also tried changing "Require" to
"Allow") in the root designer and all controls are now visible in the
toolbox. So even though you've never used ToolboxItemFilt erAttribute,
your understanding of it is correct.

I didn't touch the attribute in MarqueeBorder & MarqueeText. I guess I
don't understand the purpose of including the attribute there, but I
can live with that.

Thanks again for all of your help.

Nov 27 '06 #7
Hi,
I commented out the two lines (and also tried changing "Require" to
"Allow") in the root designer and all controls are now visible in the
toolbox. So even though you've never used ToolboxItemFilt erAttribute,
your understanding of it is correct.
Thanks for the verification :)
I didn't touch the attribute in MarqueeBorder & MarqueeText. I guess I
don't understand the purpose of including the attribute there, but I
can live with that.
If you're curious, the following article provides some information about how
the Toolbox uses the ToolboxItemFilt erAttribute when its present on a
component or a designer class:

"ToolboxItemFil terType Enumeration"
http://msdn2.microsoft.com/en-us/lib...iltertype.aspx

--
Dave Sexton

"John D'oh" <cb*******@gmai l.comwrote in message
news:11******** *************@4 5g2000cws.googl egroups.com...
Hi,
Aargh, now I don't think I'll ever be able to figure out what the
problem was. If you have any ideas, I'd love to know what I initially
did wrong.
I'm still not sure what went wrong.
Now that I look back on it, I'm wondering if your tip about "Reset
Toolbox" is what finally got things working.
>If you add a component to your designer from the
Toolbox (e.g., BackgroundWorke r or FileSystemWatch er) then you'll see the
component tray appear at the bottom of the control designer. The
component
designer is basically a full-screen component tray. There are no resize
handles and no "visual" way to design the graphical interface of the
component. Therefore, you are limited to only being able to add
components
from the Toolbox, but not controls that provide a graphical interface.
If
you want to see the component designer, create a class that derives from
System.Compone ntModel.Compone nt instead of UserControl.
OK, I understand and know what you're talking about. I've just always
called both of them the designers and never distinguished the two.
Thanks for clearing that up.
Therefore, MarqueeControl or DemoMarqueeCont rol would act like
a Panel and be the parent of the controls I added. Am I understanding
things correctly?No. When a UserControl is added to a Form's designer,
for example, it
shouldn't behave like a Panel. The idea is that a UserControl
encapsulates ,
usually compositing, a graphical interface. When you add the UserControl
to
a Form's designer you should think of it as a standard control such as a
TextBox or Label. If you want a control that behaves as Panel does, then
you must derive from Panel or ContainerContro l, for example, but not
UserControl (an alternative to inheritance is to use the appropriate
designer, which I believe is ParentControlDe signer, IIRC).
OK, I understand this now and it makes perfect sense.
>So it seems that the tutorial did not intend for MarqueeControl and its
derived classes to contain just any Control, but only the two listed
above.
If you change "Require" to "Allow", or just remove both of the attributes
from MarqueeControlR ootDesigner altogether, then you should be able to
add
all Controls to the MarqueeControl' s designer from the Toolbox and not
just
the two listed above. If not, then try removing the ToolboxItemFilt er
attributes from the MarqueeBorder and MarqueeText controls as well. I'm
not
sure of the exact behavior of ToolboxItemFilt erAttribute since I haven't
used it myself.
I commented out the two lines (and also tried changing "Require" to
"Allow") in the root designer and all controls are now visible in the
toolbox. So even though you've never used ToolboxItemFilt erAttribute,
your understanding of it is correct.

I didn't touch the attribute in MarqueeBorder & MarqueeText. I guess I
don't understand the purpose of including the attribute there, but I
can live with that.

Thanks again for all of your help.

Nov 27 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1654
by: Deltones | last post by:
Hi all, I'm just getting into Python/wxPython/Pythoncard and I'm trying the tutorial from this page: http://pythoncard.sourceforge.net/walkthrough1.html Is it me who's totally dense or there's some sort of confusion with this tutorial? Here's what is said in the tutorial:
0
1090
by: Raj | last post by:
I want to invoke Ms agents using Network Query Language. the Nql comes with a ATL COM INTERFACE (NQLATL.DLL ) and the help intro reads "The ATL COM interface (NQLATL. DLL) is a lightweight alternative to the ActiveX interface. "
2
1607
by: Michael Tholkes | last post by:
Hello, I cannot find where to download to code or dll referred to in this article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/DBGch01.asp "Production Debugging for .NET Framework Applications" I'm looking for the DebuggingCOMLib library referenced in the article. Thanks,
1
1914
by: flagisup | last post by:
I have completed the walkthrough on creating and consuming a web service. Worked fine on my local machine. I then did a project copy to my web host. When I try to access the web service using the aspx program it gives the 'Conversion Failed' message which is the try catch message I put in. Appears that the namespace is not being recognized. Any help is appreciated. thanks
9
2422
by: dennist685 | last post by:
Walkthrough: Creating a Web Page to Display Access Database Data I've started the above walkthrough. However, near the beginning it gives the following instructions To set permissions in the App_Data folder In Windows Explorer, move to the root folder for the Web site. The default location for your new Web site is c:\inetpub\wwwroot\AccessSample.
7
1744
by: John D'oh | last post by:
Hello, I have been going through the MSDN Walkthrough: Creating a Windows Forms Control That Takes Advantage of Visual Studio Design-Time Features. Everything was going fine and I was able to create and compile the MarqueeControlLibrary project. And I think I even understood most of it.
0
231
by: TonyJ | last post by:
Hello! I use VS2005 and C#. I'm looking at ADO.NET and have found some test tutorial on microsoft MSDN. It can be found on google when searching for "Walkthrough: Saving Data to a Database (Single Table)" You must have access to the Northwind sample database.
3
1679
by: Microsoft | last post by:
Hi I have a c# program that continually runs 24/7 and performs a variety of tasks based on a timer. There is one routine that hangs every Saturday morning without fail. If I restart the program throughout the week is still hangs. I can restart it immediatly after the hang and it runs fine until next Saturday. There is nothing different about Saturday that I can think of.
9
1804
by: Mythran | last post by:
Can someone please point me to some articles explaining how to convert the code comment xml files into MSDN documentation? I've made some modifications to Enterprise Library and would like to create the msdn documentation for my changes (which have been documented using code comments following the same patterns that the P&P guys use)...since these assemblies will be used by my co-workers, the MSDN docs should be updated to reflect my...
0
8246
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8490
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.