text alignment and buttons

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Brown

    #1

    text alignment and buttons

    I have a problem where, depending on the text of a button, the display of
    that text seems to change size or alignment.

    Here is the code:

    HomeScoreNameBu tton.ForeColor = Color.Green;
    HomeScoreNameBu tton.Font = new System.Drawing. Font("Tahoma",
    8.50F, System.Drawing. FontStyle.Regul ar,
    System.Drawing. GraphicsUnit.Po int, ((System.Byte)( 0));
    this.HomeScoreN ameButton.Locat ion = new System.Drawing. Location(10,10) ;
    this.HomeScoreN ameButton.Name = "HomeScoreNameB utton";
    this.HomeScoreN ameButton.Size = new System.Drawing. Size(24,16);
    this.HomeScoreN ameButton.Text = "Sunset";
    this.HomeScoreN ameButton.TextA lign = System.Drawing. ContentAlignmen t.MiddleRight;

    the buttons are small (24,16) for a reason, and I can't make them bigger.
    when the text of the button (which changes), is too long to display, it is
    simply truncated from the right.

    If the button text is "Sunset Girls", then it displays as "Sunset G"
    (truncated to fit), and displays properly.

    However, if the text is "Sunset Boys", then it displays as "Sunset"
    (truncated), which is fine, but now the "S" (capital S) loses the topmost
    line of the font, as if the vertical alignment of the button text has
    changed, or the size of the font has changed.

    Any ideas about what is happening?

    Terry Brown



  • Lebesgue

    #2
    Re: text alignment and buttons

    I believe this has nothing to do whith C#, nor .NET WinForms. I would say
    this is a Windows problem.

    "Terry Brown" <tthkbw@gmail.c om> wrote in message
    news:pan.2006.0 1.13.17.19.11.4 625@gmail.com.. .[color=blue]
    >I have a problem where, depending on the text of a button, the display of
    > that text seems to change size or alignment.
    >
    > Here is the code:
    >
    > HomeScoreNameBu tton.ForeColor = Color.Green;
    > HomeScoreNameBu tton.Font = new System.Drawing. Font("Tahoma",
    > 8.50F, System.Drawing. FontStyle.Regul ar,
    > System.Drawing. GraphicsUnit.Po int, ((System.Byte)( 0));
    > this.HomeScoreN ameButton.Locat ion = new
    > System.Drawing. Location(10,10) ;
    > this.HomeScoreN ameButton.Name = "HomeScoreNameB utton";
    > this.HomeScoreN ameButton.Size = new System.Drawing. Size(24,16);
    > this.HomeScoreN ameButton.Text = "Sunset";
    > this.HomeScoreN ameButton.TextA lign =
    > System.Drawing. ContentAlignmen t.MiddleRight;
    >
    > the buttons are small (24,16) for a reason, and I can't make them bigger.
    > when the text of the button (which changes), is too long to display, it is
    > simply truncated from the right.
    >
    > If the button text is "Sunset Girls", then it displays as "Sunset G"
    > (truncated to fit), and displays properly.
    >
    > However, if the text is "Sunset Boys", then it displays as "Sunset"
    > (truncated), which is fine, but now the "S" (capital S) loses the topmost
    > line of the font, as if the vertical alignment of the button text has
    > changed, or the size of the font has changed.
    >
    > Any ideas about what is happening?
    >
    > Terry Brown
    > www.stickmansoftware.com
    >
    >[/color]


    Comment

    • Alan Pretre

      #3
      Re: text alignment and buttons

      "Terry Brown" <tthkbw@gmail.c om> wrote in message
      news:pan.2006.0 1.13.17.19.11.4 625@gmail.com.. .[color=blue]
      >I have a problem where, depending on the text of a button, the display of
      > that text seems to change size or alignment.[/color]

      Try setting the buttons' FlatStyle to System.

      -- Alan


      Comment

      • Terry Brown

        #4
        Re: text alignment and buttons

        On Fri, 13 Jan 2006 12:03:29 -0600, Alan Pretre wrote:

        Thanks! That fixes the problem.

        I hesitate to ask why . . .

        [color=blue]
        > "Terry Brown" <tthkbw@gmail.c om> wrote in message
        > news:pan.2006.0 1.13.17.19.11.4 625@gmail.com.. .[color=green]
        >>I have a problem where, depending on the text of a button, the display of
        >> that text seems to change size or alignment.[/color]
        >
        > Try setting the buttons' FlatStyle to System.
        >
        > -- Alan[/color]

        Comment

        • Alan Pretre

          #5
          Re: text alignment and buttons

          "Terry Brown" <tthkbw@gmail.c om> wrote in message
          news:pan.2006.0 1.13.18.35.42.3 79625@gmail.com ...[color=blue]
          > I hesitate to ask why . . .[/color]

          Not sure of the reason, didn't see this problem in .NET 1.1, seems to have
          arisen in .NET 2.0.

          -- Alan


          Comment

          • Bruce Wood

            #6
            Re: text alignment and buttons

            Are you sure that it's not attempting to wrap the next word onto the
            "next line" on the button, of which there is none, and shoving the
            "first line" up farther to compensate?

            Comment

            • Alan Pretre

              #7
              Re: text alignment and buttons

              "Bruce Wood" <brucewood@cana da.com> wrote in message
              news:1137187182 .493051.190720@ g44g2000cwa.goo glegroups.com.. .[color=blue]
              > Are you sure that it's not attempting to wrap the next word onto the
              > "next line" on the button, of which there is none, and shoving the
              > "first line" up farther to compensate?[/color]

              Yes it is doing that, but it does it differently depending on that
              FlatStyle. All I am saying is that the behavior has changed, I did not see
              that behavior in my apps when it was built for .NET 1.1.

              -- Alan


              Comment

              • Terry Brown

                #8
                Re: text alignment and buttons

                On Fri, 13 Jan 2006 15:27:24 -0600, Alan Pretre wrote:

                This makes sense to me. Thanks for the discussion. If this is true
                (two lines generated) then I can fix the problem my manually truncating
                the string to size. I'll give it a shot.

                Terry
                [color=blue]
                > "Bruce Wood" <brucewood@cana da.com> wrote in message
                > news:1137187182 .493051.190720@ g44g2000cwa.goo glegroups.com.. .[color=green]
                >> Are you sure that it's not attempting to wrap the next word onto the
                >> "next line" on the button, of which there is none, and shoving the
                >> "first line" up farther to compensate?[/color]
                >
                > Yes it is doing that, but it does it differently depending on that
                > FlatStyle. All I am saying is that the behavior has changed, I did not
                > see that behavior in my apps when it was built for .NET 1.1.
                >
                > -- Alan[/color]

                Comment

                Working...