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

TextAlign property ?

How does one align text in a textbox?

I tried this,
lblPrompt.TextAlign = ContentAlignment.MiddleCenter;

but it always displays to the far right. I even set it in the control's
property on the design form and still it goes way to the right. The
only way I was able to get it to work properly was to position the
control way to the left. Why is it when I center the control on the
form, the text that I send to the label will not align properly.
Z.K.
Sep 27 '08 #1
3 2248
Z.K. wrote:
How does one align text in a textbox?

I tried this,
lblPrompt.TextAlign = ContentAlignment.MiddleCenter;

but it always displays to the far right. I even set it in the control's
property on the design form and still it goes way to the right. The
only way I was able to get it to work properly was to position the
control way to the left. Why is it when I center the control on the
form, the text that I send to the label will not align properly.
Z.K.

Okay I finally got it to work by setting AutoSize = false. I really
think that I like MFC in C++ better than these forms in C#.

Z.K.
Sep 27 '08 #2
On Sep 27, 3:58*am, "Z.K." <nos...@nospam.netwrote:
Z.K. wrote:
How does one align text in a textbox?
I tried this,
* *lblPrompt.TextAlign = ContentAlignment.MiddleCenter;
but it always displays to the far right. *I even set it in the control's
property on the design form and still it goes way to the right. *The
only way I was able to get it to work properly was to position the
control way to the left. *Why is it when I center the control on the
form, the text that I send to the label will not align properly.
* * Z.K.

Okay I finally got it to work by setting AutoSize = false. *I really
think that I like MFC in C++ better than these forms in C#.

* * *Z.K.
not really!!! it seems, you were more habituated to MFC... :-;

-Cnu
Sep 27 '08 #3
Duggi wrote:
On Sep 27, 3:58 am, "Z.K." <nos...@nospam.netwrote:
>Z.K. wrote:
>>How does one align text in a textbox?
I tried this,
lblPrompt.TextAlign = ContentAlignment.MiddleCenter;
but it always displays to the far right. I even set it in the control's
property on the design form and still it goes way to the right. The
only way I was able to get it to work properly was to position the
control way to the left. Why is it when I center the control on the
form, the text that I send to the label will not align properly.
Z.K.
Okay I finally got it to work by setting AutoSize = false. I really
think that I like MFC in C++ better than these forms in C#.

Z.K.

not really!!! it seems, you were more habituated to MFC... :-;

-Cnu
You are probably right. I guess I just need to get used to the .NET form.

Z.K.
Sep 28 '08 #4

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

Similar topics

3
by: Johnny M | last post by:
using Access 2003 Pardon the subject line, but I don't have a better word for this strange behavior (or behavior I don't understand!!!) I have a class module named DepreciationFactor. One of...
7
by: MP | last post by:
Hello, I am trying to write a class that will expose some properties. One of the property is extracted from a SQL database and can be NULL or some integer value. Is there a elegant way of...
1
by: Kyle Blaney | last post by:
When labels are vertically stacked on top of one another and have their TextAlign property set to MiddleRight, the text is not properly right-aligned. You can reproduce this problem by creating...
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
15
by: Lauren Wilson | last post by:
Owning your ideas: An essential tool for freedom By Daniel Son Thinking about going into business? Have an idea that you think will change the world? What if you were told that there was no way...
0
by: Fabio | last post by:
Hi all! I need to implement the RightToLeft feature in a Graphics.DrawString(). I set the StringFormatFlags.DirectionRightToLeft to the StringFormat but... I don't see any difference between the...
2
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I'm using the VS 2005 Express Edition for C#. In the GUI designer, when I try to set the text alignment to anything except Left for the first column of a ListView, it jumps back to the...
1
by: daleykd | last post by:
Hello all. I've been pulled out my hair all day trying to figure this one out. In VB .NET 2.0, I'm attempting to create a custom control inheriting a TextBox. I've attempted to do a: ...
1
by: cday119 | last post by:
I have a Class with about 10 properties. All properties return right except for one. It is real annoying and I can't see why its not working. Maybe someone else can see something. It is the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
1
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
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...

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.