Right aligning Labels 
Author Message
 Right aligning Labels

You gave them the same with...did you gave em also the same left-position?
or..if you don't give em same with...you need to calculate their
right-position
with something like this (i think) lbl2.left = lbl1.left+lbl1.width -
lbl2.width

Probably this is the problem i think....

greetz sotto


Quote:
> I have a just created 6 labels all the same width, and the right alignment
> doesn't seem to work correctly.

> The labels are Labeled - Surname, Initials, Title, Salutation, Department,
> Company.
> As you can see in the attached picture I have right aligned them.  The
blue
> picture box next to them clearly shows some of the text to further over
than
> others.

> Is the a bug?

> Many thanks
> Chris



Tue, 01 Feb 2005 17:58:27 GMT  
 Right aligning Labels
Yes, I read somewhere that right aligning text has some bugs.  If you set
the textsize to 9 or 17 it aligns correctly.  (I know that that is no
solution but is shows the error)


Quote:
> I have a just created 6 labels all the same width, and the right alignment
> doesn't seem to work correctly.

> The labels are Labeled - Surname, Initials, Title, Salutation, Department,
> Company.
> As you can see in the attached picture I have right aligned them.  The
blue
> picture box next to them clearly shows some of the text to further over
than
> others.

> Is the a bug?

> Many thanks
> Chris



Tue, 01 Feb 2005 20:20:28 GMT  
 Right aligning Labels
Thanks,
I guess I'll just have to stick to left aligning them until a fix is
available.  (note: I noticed when you set the RightToLeft property, they
line up correctly).

Chris



Quote:
> Yes, I read somewhere that right aligning text has some bugs.  If you set
> the textsize to 9 or 17 it aligns correctly.  (I know that that is no
> solution but is shows the error)



> > I have a just created 6 labels all the same width, and the right
alignment
> > doesn't seem to work correctly.

> > The labels are Labeled - Surname, Initials, Title, Salutation,
Department,
> > Company.
> > As you can see in the attached picture I have right aligned them.  The
> blue
> > picture box next to them clearly shows some of the text to further over
> than
> > others.

> > Is the a bug?

> > Many thanks
> > Chris



Tue, 01 Feb 2005 20:55:11 GMT  
 Right aligning Labels
[Reply posted to group and cc: to author as a courtesy (if no 'spam guard')]
Please do not reply directly to the e-mail

Quote:
>I have a just created 6 labels all the same width, and the right alignment
>doesn't seem to work correctly.

>The labels are Labeled - Surname, Initials, Title, Salutation, Department,
>Company.
>As you can see in the attached picture I have right aligned them.  The blue
>picture box next to them clearly shows some of the text to further over than
>others.

I posted the following message in
microsoft.public.dotnet.framework.windowsforms.designtime on 8/14/2002:

---- Begin Quote ----

Sounds similar to the following. I've edited the original e-mail to protect the
innocent. Read the thread from the bottom up.

=============================

Suggestion 1

Setting the font size to an integer settles this. (Well, not completely, yet
better.)

Suggestion 2 (from Microsoft)

This issue arises because the Label is drawn using GDI+ which measures and draws
characters differently <from when using GDI>. One way to work around this
drawing issue and have your labels look good with right justification is to
create your own class that inherits from Label. Override CreateParams, and
specify SS_RIGHT as part of the style. Here is some code to do this:

public myRightAlignedLabel: Label
  Protected override System.Windows.Forms.CreateParams CreateParams{
     get {
          CreateParams cp = base.CreateParams;
           int SS_RIGHT = 0x00000002;
           cp.Style |= SS_RIGHT;

           return cp;
     }
  }

This will cause the operating system to draw your label's text using GDI, not
GDI+. Replace the Label control with your myRightAlignedLabel control everywhere
you need a right aligned label.

Quote:
-----Original Message-----

It's my pleasure to work with you again for this issue. On further research,
I've found that this is a known problem with some fonts and it is caused by the
fact that text rendering in GDI+ is device resolution independent. One
workaround is to switch the font of labels from Microsoft Sans Serif to be
Courier New. Please let me know if this option would work in your scenario. I'll
research more to see if there is any other workaround.

-----Original Message-----

This is xxxxxxxxxxx from Microsoft Developer Support. I've taken ownership of
the issue about right text align not aligning text correctly on labels. I was
able to reproduce the problem with your sample. I'll research further and let
you know my findings. In the meantime, if you have any questions/concerns
regarding this issue, please do not hesitate to contact me.

=============================



Tue, 01 Feb 2005 21:52:52 GMT  
 Right aligning Labels
Great, thanks for the info Craig

Chris


Quote:

> [Reply posted to group and cc: to author as a courtesy (if no 'spam
guard')]
> Please do not reply directly to the e-mail

> >I have a just created 6 labels all the same width, and the right
alignment
> >doesn't seem to work correctly.

> >The labels are Labeled - Surname, Initials, Title, Salutation,
Department,
> >Company.
> >As you can see in the attached picture I have right aligned them.  The
blue
> >picture box next to them clearly shows some of the text to further over
than
> >others.

> I posted the following message in
> microsoft.public.dotnet.framework.windowsforms.designtime on 8/14/2002:

> ---- Begin Quote ----

> Sounds similar to the following. I've edited the original e-mail to
protect the
> innocent. Read the thread from the bottom up.

> =============================

> Suggestion 1

> Setting the font size to an integer settles this. (Well, not completely,
yet
> better.)

> Suggestion 2 (from Microsoft)

> This issue arises because the Label is drawn using GDI+ which measures and
draws
> characters differently <from when using GDI>. One way to work around this
> drawing issue and have your labels look good with right justification is
to
> create your own class that inherits from Label. Override CreateParams, and
> specify SS_RIGHT as part of the style. Here is some code to do this:

> public myRightAlignedLabel: Label
>   Protected override System.Windows.Forms.CreateParams CreateParams{
>      get {
>           CreateParams cp = base.CreateParams;
>            int SS_RIGHT = 0x00000002;
>            cp.Style |= SS_RIGHT;

>            return cp;
>      }
>   }

> This will cause the operating system to draw your label's text using GDI,
not
> GDI+. Replace the Label control with your myRightAlignedLabel control
everywhere
> you need a right aligned label.

> -----Original Message-----

> It's my pleasure to work with you again for this issue. On further
research,
> I've found that this is a known problem with some fonts and it is caused
by the
> fact that text rendering in GDI+ is device resolution independent. One
> workaround is to switch the font of labels from Microsoft Sans Serif to be
> Courier New. Please let me know if this option would work in your
scenario. I'll
> research more to see if there is any other workaround.

> -----Original Message-----

> This is xxxxxxxxxxx from Microsoft Developer Support. I've taken ownership
of
> the issue about right text align not aligning text correctly on labels. I
was
> able to reproduce the problem with your sample. I'll research further and
let
> you know my findings. In the meantime, if you have any questions/concerns
> regarding this issue, please do not hesitate to contact me.

> =============================



Tue, 01 Feb 2005 23:10:56 GMT  
 Right aligning Labels
I wonder if Microsoft stated that "It is by design" when they post the
solution... :)


Quote:
> Great, thanks for the info Craig

> Chris




> > [Reply posted to group and cc: to author as a courtesy (if no 'spam
> guard')]
> > Please do not reply directly to the e-mail

> > >I have a just created 6 labels all the same width, and the right
> alignment
> > >doesn't seem to work correctly.

> > >The labels are Labeled - Surname, Initials, Title, Salutation,
> Department,
> > >Company.
> > >As you can see in the attached picture I have right aligned them.  The
> blue
> > >picture box next to them clearly shows some of the text to further over
> than
> > >others.

> > I posted the following message in
> > microsoft.public.dotnet.framework.windowsforms.designtime on 8/14/2002:

> > ---- Begin Quote ----

> > Sounds similar to the following. I've edited the original e-mail to
> protect the
> > innocent. Read the thread from the bottom up.

> > =============================

> > Suggestion 1

> > Setting the font size to an integer settles this. (Well, not completely,
> yet
> > better.)

> > Suggestion 2 (from Microsoft)

> > This issue arises because the Label is drawn using GDI+ which measures
and
> draws
> > characters differently <from when using GDI>. One way to work around
this
> > drawing issue and have your labels look good with right justification is
> to
> > create your own class that inherits from Label. Override CreateParams,
and
> > specify SS_RIGHT as part of the style. Here is some code to do this:

> > public myRightAlignedLabel: Label
> >   Protected override System.Windows.Forms.CreateParams CreateParams{
> >      get {
> >           CreateParams cp = base.CreateParams;
> >            int SS_RIGHT = 0x00000002;
> >            cp.Style |= SS_RIGHT;

> >            return cp;
> >      }
> >   }

> > This will cause the operating system to draw your label's text using
GDI,
> not
> > GDI+. Replace the Label control with your myRightAlignedLabel control
> everywhere
> > you need a right aligned label.

> > -----Original Message-----

> > It's my pleasure to work with you again for this issue. On further
> research,
> > I've found that this is a known problem with some fonts and it is caused
> by the
> > fact that text rendering in GDI+ is device resolution independent. One
> > workaround is to switch the font of labels from Microsoft Sans Serif to
be
> > Courier New. Please let me know if this option would work in your
> scenario. I'll
> > research more to see if there is any other workaround.

> > -----Original Message-----

> > This is xxxxxxxxxxx from Microsoft Developer Support. I've taken
ownership
> of
> > the issue about right text align not aligning text correctly on labels.
I
> was
> > able to reproduce the problem with your sample. I'll research further
and
> let
> > you know my findings. In the meantime, if you have any
questions/concerns
> > regarding this issue, please do not hesitate to contact me.

> > =============================



Wed, 02 Feb 2005 00:35:26 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Right aligned text boxes don't right align

2. Problem with right align of labels on WinForm :(

3. Label Caption won't Right Align Properly

4. pixels trimmed in label if bold and right aligned

5. left align and/or right align the masked edit control under VB 5.0 SP(3)

6. Align Label Text with VBA

7. Label default text align...

8. ?? Is it Possible to Verticle Align Label.Caption ??

9. align text in label

10. Aligning ComboBox over Label

11. Vertical Align VB label

12. Right Align fields in a List

 

 
Powered by phpBB® Forum Software