473,408 Members | 2,839 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,408 software developers and data experts.

Default Properties for Controls

Hi all,

VS.Net 2002.

Is there a way to set default properties for controls in the Toolbox?

There a some properties that I implement as standard in my apps and would
like to get around setting these same basic things each time a use a
control.

TIA,

XNoDE
Nov 20 '05 #1
4 2001
Default values by and large are not allowed in VB.NET unless it is a
parameterized property, like with a collection:

collection.item(x) could be written as: collection(x)

In classic VB you could have default properties (such as .text with a
textbox) because of the difference between objects and data types

x = txtUser was clearly accessing the default .text property of the textbox
and

Set x = txtUser was clearly making x an object reference to the textbox
itself

In .NET, since everything is an object, the Set statement is irrelevant and
no longer supported. However, this created a problem:

Does x = txtUser mean that you want x to take on the .text property value
of the txtUser textbox or does it mean that you want x to become an object
reference to the textbox itself?

To clear up this ambiguity, MS did away with all default properties unless
that are properties that take parameters.

x = collection(x) clearly implies that you are talking about the .item
property of collection because there is a parameter present (x).

x = collection clearly implies that you want x to be an object reference to
the collection object.

Hope this helps.

Scott

"XNoDE" <xn***@sbcglobal.net> wrote in message
news:ec**************@TK2MSFTNGP11.phx.gbl...
Hi all,

VS.Net 2002.

Is there a way to set default properties for controls in the Toolbox?

There a some properties that I implement as standard in my apps and would
like to get around setting these same basic things each time a use a
control.

TIA,

XNoDE

Nov 20 '05 #2
So, I'm reading your post again and realizing that, you don't want to set
default PROPERTIES on the toolbox controls (as you've written), you perhaps
want to set a default VALUE for some various properties of the toolbox
controls. (Sorry for the mis-read)

The controls on the toolbox represent base classes in the .NET Framework
class libraries, so the short answer is no. However, you could make a new
control that inherits from the standard one, set whatever property values
you want and use that control instead.

Public Class MyTextBox
Inherits System.Windows.Forms.Textbox

Public Sub New()
me.Text = "Some default value."
End Sub
End Class

HTH!

Scott

"XNoDE" <xn***@sbcglobal.net> wrote in message
news:ec**************@TK2MSFTNGP11.phx.gbl...
Hi all,

VS.Net 2002.

Is there a way to set default properties for controls in the Toolbox?

There a some properties that I implement as standard in my apps and would
like to get around setting these same basic things each time a use a
control.

TIA,

XNoDE

Nov 20 '05 #3
Thanks Scott,

Sorry for the mistype, I guess I wasn't really sure how to ask for what I
wanted. Your second post is correct. If for example I would like all of my
buttons to have the default values as:

FlatStyle = Flat
Size = 96,20

etc..

Is there a way I can have these values preset to my liking so that I only
have to build the form and code? I know it seems a trivial thing, but it's
a preference of mine.

If so, how. If I create the new class that you mention, how do I save it as
a control so that I can add it to my forms at leisure? I am familiar with
creating the class files but I've never coded extensions to a control.

Thanks again,

Xnode
"Scott M." <s-***@badspamsnet.net> wrote in message
news:OV**************@TK2MSFTNGP11.phx.gbl...
So, I'm reading your post again and realizing that, you don't want to set
default PROPERTIES on the toolbox controls (as you've written), you perhaps want to set a default VALUE for some various properties of the toolbox
controls. (Sorry for the mis-read)

The controls on the toolbox represent base classes in the .NET Framework
class libraries, so the short answer is no. However, you could make a new
control that inherits from the standard one, set whatever property values
you want and use that control instead.

Public Class MyTextBox
Inherits System.Windows.Forms.Textbox

Public Sub New()
me.Text = "Some default value."
End Sub
End Class

HTH!

Scott

"XNoDE" <xn***@sbcglobal.net> wrote in message
news:ec**************@TK2MSFTNGP11.phx.gbl...
Hi all,

VS.Net 2002.

Is there a way to set default properties for controls in the Toolbox?

There a some properties that I implement as standard in my apps and would like to get around setting these same basic things each time a use a
control.

TIA,

XNoDE


Nov 20 '05 #4
I haven't done this myself, but look into building a custom server control.
These can be added to your toolbox so that you can place them on forms just
like any other control.
"XNoDE" <xn***@sbcglobal.net> wrote in message
news:ev*************@TK2MSFTNGP10.phx.gbl...
Thanks Scott,

Sorry for the mistype, I guess I wasn't really sure how to ask for what I
wanted. Your second post is correct. If for example I would like all of my buttons to have the default values as:

FlatStyle = Flat
Size = 96,20

etc..

Is there a way I can have these values preset to my liking so that I only
have to build the form and code? I know it seems a trivial thing, but it's a preference of mine.

If so, how. If I create the new class that you mention, how do I save it as a control so that I can add it to my forms at leisure? I am familiar with
creating the class files but I've never coded extensions to a control.

Thanks again,

Xnode
"Scott M." <s-***@badspamsnet.net> wrote in message
news:OV**************@TK2MSFTNGP11.phx.gbl...
So, I'm reading your post again and realizing that, you don't want to set
default PROPERTIES on the toolbox controls (as you've written), you

perhaps
want to set a default VALUE for some various properties of the toolbox
controls. (Sorry for the mis-read)

The controls on the toolbox represent base classes in the .NET Framework
class libraries, so the short answer is no. However, you could make a new control that inherits from the standard one, set whatever property values you want and use that control instead.

Public Class MyTextBox
Inherits System.Windows.Forms.Textbox

Public Sub New()
me.Text = "Some default value."
End Sub
End Class

HTH!

Scott

"XNoDE" <xn***@sbcglobal.net> wrote in message
news:ec**************@TK2MSFTNGP11.phx.gbl...
Hi all,

VS.Net 2002.

Is there a way to set default properties for controls in the Toolbox?

There a some properties that I implement as standard in my apps and

would like to get around setting these same basic things each time a use a
control.

TIA,

XNoDE



Nov 20 '05 #5

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

Similar topics

8
by: deko | last post by:
I'm trying to find a way to set form/control properties programmatically. In a nut shell: 1. Open a database 2. Open a form in design view 3. Do something like this: For Each prp In...
8
by: deko | last post by:
I'm hoping someone can sanity check my understanding of the Object Model for Forms/Controls. I'm having trouble drilling down into Control properties. First, I have a record set with the...
3
by: countd4 | last post by:
I have built a working user control. However, to make it work, I always have to set certian properties using the properties sheet for the control when using it on other forms. I want to be able to...
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...
4
by: Dennis | last post by:
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...
2
by: Bob | last post by:
I have a CreatedOn field , datetime, which has GetDate() as the default value in SQL server 2000 table. When I create a new record in the table itself in enterprise manager, the field gets...
2
by: Rolf Welskes | last post by:
Hello, I have writen a simple aspnet control MyCtrl and want to use it as follows: (c01 may be the tag-prefix): <c01:MyCtrl>this is a simple text</c01:MyCtrl>. The control-code:
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...
10
by: Derek Hart | last post by:
I am going in circles trying to loop through properties on 3rd party controls. For example, I have a textbox that has its maximum length located at MyTextBox.Properties.MaxLength - instead of the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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
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,...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.