473,322 Members | 1,714 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,322 software developers and data experts.

TextBox's property

I create my own usercontrol (textbox), I new a property 'Type'
I will set this property during design mode, I will set 'I' OR 'C', i stands
for integer, c stands for character,
Now, In that usercontrol, I want to detect that property , if the propety
set to "I", the textalign will set to 'right'

iF ME.TYPE ='I"
Me.textAlign = HorizontalAlignment.Right
endif
if Me.type = "C"
Me.textAlign = HorizontalAlignment.left
endif

I put the above code in InitLayout(), but it seems didn't work . Where
Should I place these code ???
Thanks a lot
Nov 21 '05 #1
6 1633
Hi,

I think it isn't working because a textbox doesn't have a
HorizontalAlignment. Labels do though. But textboxes are always aligned on
the left side. So if you inherit from Label instead of Textbox you should
be on the right track. Do you have VS.Net? It will show the properties
available. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I create my own usercontrol (textbox), I new a property 'Type'
I will set this property during design mode, I will set 'I' OR 'C', i stands for integer, c stands for character,
Now, In that usercontrol, I want to detect that property , if the propety
set to "I", the textalign will set to 'right'

iF ME.TYPE ='I"
Me.textAlign = HorizontalAlignment.Right
endif
if Me.type = "C"
Me.textAlign = HorizontalAlignment.left
endif

I put the above code in InitLayout(), but it seems didn't work . Where
Should I place these code ???
Thanks a lot

Nov 21 '05 #2

"Agnes" <ag***@dynamictech.com.hk> wrote
I create my own usercontrol (textbox), I new a property 'Type'
I will set this property during design mode, I will set 'I' OR 'C', i stands
for integer, c stands for character,
First, that should be an Enumeration,

Second "Type" is a basic variable type, it would be best to choose
some other name

Now, In that usercontrol, I want to detect that property , if the propety
set to "I", the textalign will set to 'right'
I put the above code in InitLayout(), but it seems didn't work . Where
Should I place these code ???
Thanks a lot

You should put it in the public property. For example, if your control
has only one textbox, then you don't need to keep a variable at all, you
can just set and return the value directly from the textbox:
Public Property TextAlign() As Windows.Forms.HorizontalAlignment
Get
Return Me.TextBox1.TextAlign
End Get
Set(ByVal Value As Windows.Forms.HorizontalAlignment)
Me.TextBox1.TextAlign = Value
End Set
End Property
Also, if you plan to let others use it, you might want to add attributes
to set the defaults, and add a description. Attributes go ahead of the
property declaration:

<ComponentModel.Category("Appearance"), ComponentModel.Description("Indicates how the text should be aligned."), _
ComponentModel.Browsable(True), ComponentModel.DefaultValue(Windows.Forms.Horizont alAlignment.Left)> _
Public Property TextAlign() As Windows.Forms.HorizontalAlignment
(That is all on one line, note the _ continuation character)

(Also: Imports System was assumed, otherwise use:
System.ComponentModel....)

HTH
LFS
Nov 21 '05 #3
Hi,

Disregard my last reply. I was thinking an ASP:Textbox, not a Windows Forms
control. Ken.

"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

I think it isn't working because a textbox doesn't have a
HorizontalAlignment. Labels do though. But textboxes are always aligned on the left side. So if you inherit from Label instead of Textbox you should
be on the right track. Do you have VS.Net? It will show the properties
available. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I create my own usercontrol (textbox), I new a property 'Type'
I will set this property during design mode, I will set 'I' OR 'C', i

stands
for integer, c stands for character,
Now, In that usercontrol, I want to detect that property , if the propety set to "I", the textalign will set to 'right'

iF ME.TYPE ='I"
Me.textAlign = HorizontalAlignment.Right
endif
if Me.type = "C"
Me.textAlign = HorizontalAlignment.left
endif

I put the above code in InitLayout(), but it seems didn't work . Where
Should I place these code ???
Thanks a lot


Nov 21 '05 #4
Larry, I was curious by your comment "that should be an enumeration". I
gathered that you thought that "type" property should not only have it's name
changed to avoid conflicts but also is should be an enumeration rather than a
property. I am new to VB.Net and was wondering exactly what you meant by
this. I looked at the help on enumerations but was unable to grasp your
intent. Thanks for any clarification.

"Larry Serflaten" wrote:

"Agnes" <ag***@dynamictech.com.hk> wrote
I create my own usercontrol (textbox), I new a property 'Type'
I will set this property during design mode, I will set 'I' OR 'C', i stands
for integer, c stands for character,


First, that should be an Enumeration,

Second "Type" is a basic variable type, it would be best to choose
some other name

Now, In that usercontrol, I want to detect that property , if the propety
set to "I", the textalign will set to 'right'


I put the above code in InitLayout(), but it seems didn't work . Where
Should I place these code ???
Thanks a lot

You should put it in the public property. For example, if your control
has only one textbox, then you don't need to keep a variable at all, you
can just set and return the value directly from the textbox:
Public Property TextAlign() As Windows.Forms.HorizontalAlignment
Get
Return Me.TextBox1.TextAlign
End Get
Set(ByVal Value As Windows.Forms.HorizontalAlignment)
Me.TextBox1.TextAlign = Value
End Set
End Property
Also, if you plan to let others use it, you might want to add attributes
to set the defaults, and add a description. Attributes go ahead of the
property declaration:

<ComponentModel.Category("Appearance"), ComponentModel.Description("Indicates how the text should be aligned."), _
ComponentModel.Browsable(True), ComponentModel.DefaultValue(Windows.Forms.Horizont alAlignment.Left)> _
Public Property TextAlign() As Windows.Forms.HorizontalAlignment
(That is all on one line, note the _ continuation character)

(Also: Imports System was assumed, otherwise use:
System.ComponentModel....)

HTH
LFS

Nov 21 '05 #5

"Dennis" <De****@discussions.microsoft.com> wrote
Larry, I was curious by your comment "that should be an enumeration". I
gathered that you thought that "type" property should not only have it's name
changed to avoid conflicts but also is should be an enumeration rather than a
property. I am new to VB.Net and was wondering exactly what you meant by
this. I looked at the help on enumerations but was unable to grasp your
intent. Thanks for any clarification.

The intent to was to suggest making that control look and feel more like
other controls.

Put a textbox (for example) on a form and change its TextAlign property.
You'll note to do that, you select from a drop down list. The method to
get the property grid to display that drop down list is to use an enumeration.

More over, using a character to effect behavior or appearance is also not
a very common approach. Look around, see if you can find a property that
want's you to enter a character, where the character effects behaviour or
appearance, and not a value or state. (ie, not a Text value or Name property)

As developers, we really need to think about what our users expect from
an application (or other piece of software). The advantage of Windows
is that many tasks are common across many applications which allows
the users to quickly grasp how to get things done, without a large amount
of learning new processes. The same goes for that small control, as it
does for a full blown application. If it acts and responds like many of
the other controls, the developers who need to put it to use already have
a large part of the knowlege they need to interact with it.

Finally, enumerations help to document code. Which would be easier
to read and understand:

control.TextAlign = "i"

Or

control.TextAlign = HorizontalAlignment.Right

As you see, "i" says nothing about what the property is beng set to do....

LFS
Nov 21 '05 #6
Thanks.

"Larry Serflaten" wrote:

"Dennis" <De****@discussions.microsoft.com> wrote
Larry, I was curious by your comment "that should be an enumeration". I
gathered that you thought that "type" property should not only have it's name
changed to avoid conflicts but also is should be an enumeration rather than a
property. I am new to VB.Net and was wondering exactly what you meant by
this. I looked at the help on enumerations but was unable to grasp your
intent. Thanks for any clarification.

The intent to was to suggest making that control look and feel more like
other controls.

Put a textbox (for example) on a form and change its TextAlign property.
You'll note to do that, you select from a drop down list. The method to
get the property grid to display that drop down list is to use an enumeration.

More over, using a character to effect behavior or appearance is also not
a very common approach. Look around, see if you can find a property that
want's you to enter a character, where the character effects behaviour or
appearance, and not a value or state. (ie, not a Text value or Name property)

As developers, we really need to think about what our users expect from
an application (or other piece of software). The advantage of Windows
is that many tasks are common across many applications which allows
the users to quickly grasp how to get things done, without a large amount
of learning new processes. The same goes for that small control, as it
does for a full blown application. If it acts and responds like many of
the other controls, the developers who need to put it to use already have
a large part of the knowlege they need to interact with it.

Finally, enumerations help to document code. Which would be easier
to read and understand:

control.TextAlign = "i"

Or

control.TextAlign = HorizontalAlignment.Right

As you see, "i" says nothing about what the property is beng set to do....

LFS

Nov 21 '05 #7

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

Similar topics

4
by: Chumley the Walrus | last post by:
I'm using this sql parameter: MyCommand.Parameters("@Sport").value = Server.HtmlEncode(sport) to get a value from a textbox control: <asp:TextBox Name="sport" id="sport"...
0
by: Jonas L | last post by:
Hi, I need to create a textbox which acts as a normal textbox but with the following extra requirements: 1) In-focus color, when the textbox gets focus the backcolor property of the textbox...
1
by: Martin | last post by:
Dear Group Sorry for bothering you again but I need expert advice on this. I have placed a HTML textbox on my aspx form and converted it to run as a server control. At some point in my code I...
2
by: Alex Shirley | last post by:
HI I'm trying to iterate through all the textboxes on a webpage and trim them for spaces. i.e. If a user enters " hello world " we correct it to "hello world" So far I've come up with...
7
by: siddhiash | last post by:
Hi Friends I want to add PasswordChar Property which shows ****** for string which I type in PropertyGrid Control. Regards, Siddharth
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
6
by: JohnR | last post by:
I have a table with 1 row which is used to hold some application wide items (one item per field, hence I only need 1 row). I want to bind one of the fields to a textbox. After setting up the...
1
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
4
by: Dean Slindee | last post by:
Anyone got a quick and easy way to change the background color on a textbox after the user has change the text value. Already have lots of forms written, so an approach that does not depend on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.