473,546 Members | 2,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Derived Control Default Design Properties

I am trying to set the default design proerties in a control I have derived
from the Panel Class. I thought I'd found how to do it from the MSDN but the
following line doesn't work:

Inherits System.Windows. Forms.Design.Co ntrolDesigner

I get an error saying that the Type is not defined. I cut and pasted all
the imports and line from the MSDN.

Would appreciate any help.
--
Dennis in Houston
Nov 21 '05 #1
4 2427
In a User Control Library, you can create a new UserControl class. This is
the class you would use for controls that are made of several constituent
controls. If you want to just inherit from Panel, change the last item in
the inherits statement from UserControl to Panel. In the InitializeCompo nent
routine, remove me.size = LxW.

Instead of Load, the inherited control uses:

Protected Overrides Sub OnCreateControl ()
MyBase.BackColo r = Color.Yellow
MyBase.BorderSt yle = BorderStyle.Fix ed3D
MyBase.OnCreate Control()
End Sub

Be sure that last line gets in there. The lines above that would be one way
to set defaults for existing properties. If you have an added property, you
can set the default property value in the private variable that holds the
value. If you subsequently change the value in the Properties Window, that
value would be over written.

Private _Field As String = "StartField "
Public Property Field() As String
Get
Return Me._Field
End Get
Set(ByVal Value As String)
Me._Field = Value
End Set
End Property

When you customize the toolbox, browse to the .dll created for the
UserControl Library project.

www.charlesfarriersoftware.com

"Dennis" wrote:
I am trying to set the default design proerties in a control I have derived
from the Panel Class. I thought I'd found how to do it from the MSDN but the
following line doesn't work:

Inherits System.Windows. Forms.Design.Co ntrolDesigner

I get an error saying that the Type is not defined. I cut and pasted all
the imports and line from the MSDN.

Would appreciate any help.
--
Dennis in Houston

Nov 21 '05 #2
Charlie, thanks for you answer and I learned some thing from it. However,
what I want to do is show defaults in the Properties Box at Design time. For
example, I have added a property to my derived class (derives from panel
class) for HorzAlignment and I want it to show the designer a default of
"Center" instead of the current "Near".

Thanks again for your answer.

"Charlie" wrote:
In a User Control Library, you can create a new UserControl class. This is
the class you would use for controls that are made of several constituent
controls. If you want to just inherit from Panel, change the last item in
the inherits statement from UserControl to Panel. In the InitializeCompo nent
routine, remove me.size = LxW.

Instead of Load, the inherited control uses:

Protected Overrides Sub OnCreateControl ()
MyBase.BackColo r = Color.Yellow
MyBase.BorderSt yle = BorderStyle.Fix ed3D
MyBase.OnCreate Control()
End Sub

Be sure that last line gets in there. The lines above that would be one way
to set defaults for existing properties. If you have an added property, you
can set the default property value in the private variable that holds the
value. If you subsequently change the value in the Properties Window, that
value would be over written.

Private _Field As String = "StartField "
Public Property Field() As String
Get
Return Me._Field
End Get
Set(ByVal Value As String)
Me._Field = Value
End Set
End Property

When you customize the toolbox, browse to the .dll created for the
UserControl Library project.

www.charlesfarriersoftware.com

"Dennis" wrote:
I am trying to set the default design proerties in a control I have derived
from the Panel Class. I thought I'd found how to do it from the MSDN but the
following line doesn't work:

Inherits System.Windows. Forms.Design.Co ntrolDesigner

I get an error saying that the Type is not defined. I cut and pasted all
the imports and line from the MSDN.

Would appreciate any help.
--
Dennis in Houston

Nov 21 '05 #3
Try this in your derived Panel code:

Private _HorzAlignment As String = "Near"
Public Property Field() As String
Get
Return Me._HorzAlignme nt
End Get
Set(ByVal Value As String)
Me._HorzAlignme nt = Value 'Additional code to modify HorzAlignment End Set
End Property
That should work for the Property Window. That would set the initial value
to "Near".
I have found that sometimes I have the Toolbox pointing to a .dll that is
not being updated by the Re-build. You can check that by making another
temporary change to the control that you know you would be able to see.

I might also suggest that you use an Enum for your variable type for
HorzAlignment, since it is likely a limited number of possible items.
"Dennis" wrote:
Charlie, thanks for you answer and I learned some thing from it. However,
what I want to do is show defaults in the Properties Box at Design time. For
example, I have added a property to my derived class (derives from panel
class) for HorzAlignment and I want it to show the designer a default of
"Center" instead of the current "Near".

Thanks again for your answer.

"Charlie" wrote:
In a User Control Library, you can create a new UserControl class. This is
the class you would use for controls that are made of several constituent
controls. If you want to just inherit from Panel, change the last item in
the inherits statement from UserControl to Panel. In the InitializeCompo nent
routine, remove me.size = LxW.

Instead of Load, the inherited control uses:

Protected Overrides Sub OnCreateControl ()
MyBase.BackColo r = Color.Yellow
MyBase.BorderSt yle = BorderStyle.Fix ed3D
MyBase.OnCreate Control()
End Sub

Be sure that last line gets in there. The lines above that would be one way
to set defaults for existing properties. If you have an added property, you
can set the default property value in the private variable that holds the
value. If you subsequently change the value in the Properties Window, that
value would be over written.

Private _Field As String = "StartField "
Public Property Field() As String
Get
Return Me._Field
End Get
Set(ByVal Value As String)
Me._Field = Value
End Set
End Property

When you customize the toolbox, browse to the .dll created for the
UserControl Library project.

www.charlesfarriersoftware.com

"Dennis" wrote:
I am trying to set the default design proerties in a control I have derived
from the Panel Class. I thought I'd found how to do it from the MSDN but the
following line doesn't work:

Inherits System.Windows. Forms.Design.Co ntrolDesigner

I get an error saying that the Type is not defined. I cut and pasted all
the imports and line from the MSDN.

Would appreciate any help.
--
Dennis in Houston

Nov 21 '05 #4
Charlie, you are absolutely correct. When I change the setting in my control
then rebuild it, the new values show up in the Design time Property table
exactly as I had set them to before the rebuild. Thanks a lot.

"Charlie" wrote:
Try this in your derived Panel code:

Private _HorzAlignment As String = "Near"
Public Property Field() As String
Get
Return Me._HorzAlignme nt
End Get
Set(ByVal Value As String)
Me._HorzAlignme nt = Value

'Additional code to modify HorzAlignment
End Set
End Property


That should work for the Property Window. That would set the initial value
to "Near".
I have found that sometimes I have the Toolbox pointing to a .dll that is
not being updated by the Re-build. You can check that by making another
temporary change to the control that you know you would be able to see.

I might also suggest that you use an Enum for your variable type for
HorzAlignment, since it is likely a limited number of possible items.
"Dennis" wrote:
Charlie, thanks for you answer and I learned some thing from it. However,
what I want to do is show defaults in the Properties Box at Design time. For
example, I have added a property to my derived class (derives from panel
class) for HorzAlignment and I want it to show the designer a default of
"Center" instead of the current "Near".

Thanks again for your answer.

"Charlie" wrote:
In a User Control Library, you can create a new UserControl class. This is
the class you would use for controls that are made of several constituent
controls. If you want to just inherit from Panel, change the last item in
the inherits statement from UserControl to Panel. In the InitializeCompo nent
routine, remove me.size = LxW.

Instead of Load, the inherited control uses:

Protected Overrides Sub OnCreateControl ()
MyBase.BackColo r = Color.Yellow
MyBase.BorderSt yle = BorderStyle.Fix ed3D
MyBase.OnCreate Control()
End Sub

Be sure that last line gets in there. The lines above that would be one way
to set defaults for existing properties. If you have an added property, you
can set the default property value in the private variable that holds the
value. If you subsequently change the value in the Properties Window, that
value would be over written.

Private _Field As String = "StartField "
Public Property Field() As String
Get
Return Me._Field
End Get
Set(ByVal Value As String)
Me._Field = Value
End Set
End Property

When you customize the toolbox, browse to the .dll created for the
UserControl Library project.

www.charlesfarriersoftware.com

"Dennis" wrote:

> I am trying to set the default design proerties in a control I have derived
> from the Panel Class. I thought I'd found how to do it from the MSDN but the
> following line doesn't work:
>
> Inherits System.Windows. Forms.Design.Co ntrolDesigner
>
> I get an error saying that the Type is not defined. I cut and pasted all
> the imports and line from the MSDN.
>
> Would appreciate any help.
> --
> Dennis in Houston

Nov 21 '05 #5

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

Similar topics

6
3391
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get sized strangely using the .RTFHeight property of the control. Specifically, lines of text get cut off the bottom of the control when I use the code...
2
1919
by: CroDude | last post by:
Hi all! I've made a custom group-box control derived from a GroupBox. Additionally I've made a ControlDesigner derived class associated with my group box to remove some unneeded properties. But after utilizing this ControlDesigner, I can't parent any control to my group box in a design view(When not applying ControlDesigner everything works...
7
1513
by: Jacky Luk | last post by:
Does anyone know of a downloadable Line ActiveX control which allows me to plot straight lines on a VC++.NET form? Thanks Jack
4
2094
by: jim | last post by:
I am trying to debug a user written web control and web control designer. I found an article “Building Windows Forms Controls and Component with Rich Design-Time Features” that describes how to setup debugging for a Windows Form control. I cannot find any documentation or articles on setting up the same facility for a Web control. Any...
2
1952
by: Dennis | last post by:
I have a control which I wrote that has, of course, numerous properties. These properties nicely show up at design time in the property window for the user to set their value at design time. However, their are a few that should be set only in code at run-time. How do I prevent these properties from showing up in the Properties window at...
11
8121
by: Rimpinths | last post by:
I'm new at developing user controls in C#, and one thing I've noticed right off the bat is that the constructor gets called twice -- once at design time, once at run time. In short, I'm trying to develop a control derived from DataGridView. It will have a default set of columns (but I don't want to create them via the Properties window for...
26
5341
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is because I am not always able to control/create all the different constructors the base class has. My problem can be described in code as follows ... ...
2
1895
by: PGP | last post by:
I recently derived from a ComboBox to make a countries combo and included it in couple of forms. The derived combo box loads an xml list of countries and uses the DataSource and DisplayMember properties to point to the appropriate node in xml. All this is done in the derived combo's constructor. This causes forms designer to load slower as it...
1
2215
by: =?Utf-8?B?Q2hyaXN0aWFuIFdlaW5lcnQ=?= | last post by:
Hello, I currently fight with a problem during the derivative of WinForm controls. In Visual Studio I created a new User Control. This control is derived from the DataGridView of the System.Windows.Forms namespace. I want to use this control as a template for futher controls. Within this control i want to set some property values to be...
0
7504
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, well explore What is ONU, What Is Router, ONU & Routers main...
0
7435
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7694
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. ...
0
7947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7461
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6026
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5080
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...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
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

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.