473,721 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 = HorizontalAlign ment.Right
endif
if Me.type = "C"
Me.textAlign = HorizontalAlign ment.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 1660
Hi,

I think it isn't working because a textbox doesn't have a
HorizontalAlign ment. 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***@dynamict ech.com.hk> wrote in message
news:%2******** ********@TK2MSF TNGP12.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 = HorizontalAlign ment.Right
endif
if Me.type = "C"
Me.textAlign = HorizontalAlign ment.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***@dynamict ech.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.H orizontalAlignm ent
Get
Return Me.TextBox1.Tex tAlign
End Get
Set(ByVal Value As Windows.Forms.H orizontalAlignm ent)
Me.TextBox1.Tex tAlign = 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("Appe arance"), ComponentModel. Description("In dicates how the text should be aligned."), _
ComponentModel. Browsable(True) , ComponentModel. DefaultValue(Wi ndows.Forms.Hor izontalAlignmen t.Left)> _
Public Property TextAlign() As Windows.Forms.H orizontalAlignm ent
(That is all on one line, note the _ continuation character)

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

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******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi,

I think it isn't working because a textbox doesn't have a
HorizontalAlign ment. 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***@dynamict ech.com.hk> wrote in message
news:%2******** ********@TK2MSF TNGP12.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 = HorizontalAlign ment.Right
endif
if Me.type = "C"
Me.textAlign = HorizontalAlign ment.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***@dynamict ech.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.H orizontalAlignm ent
Get
Return Me.TextBox1.Tex tAlign
End Get
Set(ByVal Value As Windows.Forms.H orizontalAlignm ent)
Me.TextBox1.Tex tAlign = 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("Appe arance"), ComponentModel. Description("In dicates how the text should be aligned."), _
ComponentModel. Browsable(True) , ComponentModel. DefaultValue(Wi ndows.Forms.Hor izontalAlignmen t.Left)> _
Public Property TextAlign() As Windows.Forms.H orizontalAlignm ent
(That is all on one line, note the _ continuation character)

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

HTH
LFS

Nov 21 '05 #5

"Dennis" <De****@discuss ions.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.TextAli gn = "i"

Or

control.TextAli gn = HorizontalAlign ment.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****@discuss ions.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.TextAli gn = "i"

Or

control.TextAli gn = HorizontalAlign ment.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
6488
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" runat="server"></asp:TextBox> but i cannot see why I get "Value of type 'System.Web.UI.WebControls.TextBox' cannot be converted to 'String'"
0
2130
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 should be set to a, selectable, in-focus color. 2) Out-of-focus color, when the textbox loses focus the backcolor property of the textbox should be set to a, selectable, out-of-focus color.
1
6709
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 assign a value to this textbox using Javascript with 'Form1.TextBox1.Value = "Hello"' But when I want to read the value of this Textbox later on using VB with 'MyVar = TextBox1.Text' it returns nothing.
2
2573
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 this:
7
9729
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
4572
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 opinion of how I want to handle the 'user experience' in the application I'm creating. While I know I could allow the user to enter in number and alpha text - in a text box - and then tell them when the execuate a command "This is not numeric data", I...
2
19870
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
13943
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 oledbconnection and dataAdapter and filling the DataSet (ds) I tried this: TextBox1.DataBindings.Add("text", ds.Tables.Item("MyFile"), "MyField") I then put the following code in the SAVE button click event:
1
3227
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' & 'Cancel'). Till this point, no problem. Initially, the TextBox is empty. The Button has a property named 'ConfirmMessage' so that the developer using this custom control can modify the question in the confirm dialog. If the user clicks 'OK', I want the...
4
8711
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 adding code to an event on every textbox would be great. Just the same, I don't see an event specifically tailored for this task (like an OnChange event). Am I missing an obvious choice? Thanks, Dean S
0
8860
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
9234
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9150
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9086
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
8028
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...
1
6678
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5994
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();...
1
3207
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
3
2146
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.