Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42215

I can't find why I can't get 'Text Align' to work.

$
0
0
Hi, I've been strugglin' with this bit of code for too long now... I can't find what I'm doing wrong or missing here...
Everything else seems to work fine, but Line 16 makes no difference whatever alignment I code the text to be.
No matter what position I select, the result is always TopCenter.

vb.net Code:
  1. Private Sub New_Buttons()
  2.         Dim x, y As Integer, c As Color, z As String
  3.         x = 70
  4.         y = 495
  5.         c = Color.Blue
  6.         z = ""
  7.  
  8.         For i = 1 To 9
  9.             Dim bt As New Button
  10.             bt.Name = "Button" & i.ToString
  11.             bt.AccessibleName = "bt(" & i.ToString & ")"
  12.             bt.Text = z
  13.             bt.Width = 40
  14.             bt.Height = 40
  15.             bt.BackColor = c
  16.             bt.TextAlign = ContentAlignment.MiddleCenter
  17.             bt.FlatAppearance.BorderSize = 0
  18.             bt.FlatStyle = FlatStyle.Flat
  19.             bt.Location = New Point(x, y)
  20.             Me.Controls.Add(bt)
  21.             Select Case i   'Atributes for NEXT button
  22.                 Case 1
  23.                     x = 110
  24.                     c = Color.Green
  25.                 Case 2
  26.                     y = 535
  27.                     c = Color.Fuchsia
  28.                 Case 3
  29.                     y = 575
  30.                     c = Bgc
  31.                 Case 4
  32.                     x = 70
  33.                     y = 590
  34.                     c = Bgc
  35.                     bt.Enabled = False
  36.                 Case 5
  37.                     x = 30
  38.                     y = 575
  39.                     c = Bgc
  40.                     bt.Enabled = False
  41.                 Case 6
  42.                     y = 535
  43.                     c = Color.Red
  44.                     bt.Enabled = False
  45.                 Case 7
  46.                     y = 495
  47.                     c = Color.Yellow
  48.                 Case 8
  49.                     x = 70
  50.                     y = 535
  51.                     c = Color.DarkOrange
  52.                 Case Else
  53.  
  54.             End Select
  55.  
  56.             AddHandler bt.Click, AddressOf ButtonClick
  57.         Next
  58.     End Sub


Poppa.

Viewing all articles
Browse latest Browse all 42215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>