473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Setting default property value for user control

Hi,

I have a user control who's class starts like this

Imports System.Drawing

Imports System.Drawing.Drawing2D

Imports System.ComponentModel

<ToolboxBitmap(GetType(Windows.Forms.Panel)), Category("test")> _

Public Class dialogTopBar

Inherits System.Windows.Forms.UserControl

what I want to do is set the dock property's default value to top so when
its added to the form it automatically docks to the top dock location, how
would I go about doing that in this declaration? thanks
Nov 21 '05 #1
6 2893
"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi,

I have a user control who's class starts like this

Imports System.Drawing

Imports System.Drawing.Drawing2D

Imports System.ComponentModel

<ToolboxBitmap(GetType(Windows.Forms.Panel)), Category("test")> _

Public Class dialogTopBar

Inherits System.Windows.Forms.UserControl

what I want to do is set the dock property's default value to top so when
its added to the form it automatically docks to the top dock location, how
would I go about doing that in this declaration? thanks


You will need a custom designer, and in the OnSetComponentDefaults override,
do something like:

MyBase.Control.Dock = ...

Let me know if you need more info on custom designers. Meantime, a look at
DesignerAttribute should point you the right direction to get going.

Best Regards,

Andy
Nov 21 '05 #2
Hi Brian,

I agree with Andy's suggestion, here goes the code.
<DesignerAttribute(GetType(TestControlDesigner)) > _
Public Class UserControl1
Inherits System.Windows.Forms.UserControl

'........ omit the generated code

End Class

Public Class TestControlDesigner
Inherits System.Windows.Forms.Design.ControlDesigner
Public Overrides Sub OnSetComponentDefaults()
MyBase.Control.Dock = DockStyle.Top
End Sub
End Class

You may also take a look at the ControlDesigner Class.
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwindowsformsdesigncontroldesignerclasst opic.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #3
i cant get the designerattribute property to show up... even with importing
all these...

Imports System

Imports System.ComponentModel

Imports System.ComponentModel.Design

Imports System.Collections

Imports System.Drawing

Imports System.Diagnostics

Imports System.Windows.Forms

Imports System.Windows.Forms.Design

""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:Kg**************@cpmsftngxa06.phx.gbl...
Hi Brian,

I agree with Andy's suggestion, here goes the code.
<DesignerAttribute(GetType(TestControlDesigner)) > _
Public Class UserControl1
Inherits System.Windows.Forms.UserControl

'........ omit the generated code

End Class

Public Class TestControlDesigner
Inherits System.Windows.Forms.Design.ControlDesigner
Public Overrides Sub OnSetComponentDefaults()
MyBase.Control.Dock = DockStyle.Top
End Sub
End Class

You may also take a look at the ControlDesigner Class.
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwindowsformsdesigncontroldesignerclasst opic.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #4
"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:uf**************@TK2MSFTNGP09.phx.gbl...
i cant get the designerattribute property to show up... even with importing all these...


Oops, that is a confusing part about attributes. You don't acually use
include "Attribute". Try this:

System.ComponentModel.Designer(GetType(...

Best Regards,

Andy
Nov 21 '05 #5
thanks that works now!
Nov 21 '05 #6
When I follow the example in the MDSN on DesignerAttrributes, for the statement

Inherits System.Windows.Forms.Design.ControlDesigner

I get an error saying that the type is not defined. I copied all the
imports and other parts directly from the MSDN using cut and paste. Any idea
what's going on?
"Andy Becker" wrote:
"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:uf**************@TK2MSFTNGP09.phx.gbl...
i cant get the designerattribute property to show up... even with

importing
all these...


Oops, that is a confusing part about attributes. You don't acually use
include "Attribute". Try this:

System.ComponentModel.Designer(GetType(...

Best Regards,

Andy

Nov 21 '05 #7

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

Similar topics

10
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
9
by: james.e.coleman | last post by:
Hello, I have created a custom dropdownlist that is used multiple times within a single page. When trying to set the values of the controls with the page in which they are being used, they all...
8
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
6
by: Rick | last post by:
I have a main form called frmDemo with a subform frmStageTrack_Sub. On the subform is a Combo Box CboTermID. The frmDemo is tied to tblDemo and the frmStageTrack_Sub is tied to tblStageTrack. ...
3
by: Mark Rae | last post by:
Hi, Just a general quickie on setting properties of user controls from the parent form. Let's say I have a user control called note.ascx which displays a datagrid. That datagrid is populated...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
0
by: joer.banno | last post by:
Hi I have a table with 2 columns, one column is a Catalogpartzone and another a webpartzone: I have a UserControl which only contains a label, this label has a public property. private...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
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...
0
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,...

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.