Lining up words in textlabel

Post

Posted
Rating:
#1 (In Topic #1593)
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 I am using a textlabel for a special view. I have 2 lines in the text label and they need to line up. I don't seem to be able to get it just right. I get close but no banana.

example of what I need

ID#       Name                  Phone                       Gender       Weight
6088     Blake the Man    907-555-1212            M                177


It is done currently with 2 lines put together with a " <br> " between them.  What I get is

ID#       Name                  Phone                       Gender       Weight
6088   Blake the Man            907-555-1212  M       177

There must be an easy way to do this that I am just not getting.
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’
…maybe you want something like :? this?

Code (gambas)

  1. TextLabel1.Text = "<TABLE cellspacing=10><TR><TD>ID#</td><TD>Name</td><TD>Phone</td><TD>Gender</td><TD>Weight</td></tr>" &
  2.                   "<TR><TD>6088</td><TD>Blake the Man</td><TD>907-555-1212</td><TD>M</td><TD>177</td></tr></table>"

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
 You could use a GridView instead.
GridView is also RichText compliant for tweaks.

but also html TABLE tags work in TextLabel RichText as vuott wisely suggested.
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’
Indeed, the use of a GridView, as suggested by colleague BruceSteer, would make word assignment easier than using html tags with the TextLabel (which would be more cumbersome).

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Guru
cogier is in the usergroup ‘Guru’
I agree that using a Gridview is probably the answer.

Try this code: -

<IMG src="https://www.cogier.com/gambas/GridviewExample.png"> </IMG>

Code (gambas)

  1. ' Gambas class file
  2.  
  3. ''Run this code in a Graphical application
  4.  
  5. Private Gridview1 As Gridview
  6.  
  7. Public Sub Form_Open()
  8.  
  9.   Dim sHeader As String[] = ["ID", "#Name", "Phone", "Gender", "Weight"]
  10.   Dim sData As String[] = ["6088", "Blake the Man", "907-555-1212", "M", "177"]
  11.   Dim iCol As Integer
  12.  
  13.   BuildForm()
  14.  
  15.   GridView1.Columns.count = sHeader.Count + 1
  16.   For iCol = 0 To sHeader.Max
  17.     GridView1.Columns[iCol].Title = sHeader[iCol]
  18.     GridView1.Columns[iCol].Alignment = Align.Center
  19.     GridView1.Font.Bold = True
  20.   Next
  21.  
  22.   For iCol = 0 To sData.Max
  23.     With GridView1
  24.       .Rows.Count = 1
  25.       .[0, iCol].Padding = 3
  26.       .[0, iCol].Text = sData[iCol]
  27.       .[0, iCol].Alignment = Align.Center
  28.       .[0, iCol].Font = Font["ubuntu,italic,14"]
  29.       .[0, iCol].Font.Bold = True
  30.       .[0, iCol].Foreground = Color.Red
  31.     End With
  32.   Next
  33.  
  34.   GridView1.Columns.Width = -1
  35.  
  36.  
  37. Public Sub BuildForm()
  38.  
  39.   .Height = 80
  40.   .Width = 450
  41.   .Arrangement = Arrange.Vertical
  42.   .Padding = 5
  43.  
  44. With Gridview1 = New GridView(Me) As "Gridview1"
  45.   .Expand = True
  46.   .Grid = False
  47.   .Header = GridView.Horizontal
  48.  
  49.  
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’

vuott said

…maybe you want something like :? this?

Code (gambas)

  1. TextLabel1.Text = "<TABLE cellspacing=10><TR><TD>ID#</td><TD>Name</td><TD>Phone</td><TD>Gender</td><TD>Weight</td></tr>" &
  2.                   "<TR><TD>6088</td><TD>Blake the Man</td><TD>907-555-1212</td><TD>M</td><TD>177</td></tr></table>"

I tried the table idea before posting. It seemed logical but the table was not supported so did not work. I will try the gridview.
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’

sadams54 said

vuott said

…maybe you want something like :? this?

Code (gambas)

  1. TextLabel1.Text = "<TABLE cellspacing=10><TR><TD>ID#</td><TD>Name</td><TD>Phone</td><TD>Gender</td><TD>Weight</td></tr>" &
  2.                   "<TR><TD>6088</td><TD>Blake the Man</td><TD>907-555-1212</td><TD>M</td><TD>177</td></tr></table>"

I tried the table idea before posting. It seemed logical but the table was not supported so did not work. I will try the gridview.

Table IS supported.
<- investigates…   : hmm seems only QT supports table but GTK does not.
Online now: No Back to the top

Post

Posted
Rating:
#8
Regular
vuott is in the usergroup ‘Regular’
Optimal results will be achieved by activating the graphic Components based on <COLOR color="#800000">QT</COLOR> resources.

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’

cogier said

I agree that using a Gridview is probably the answer.

Try this code: -

<IMG src="https://www.cogier.com/gambas/GridviewExample.png"> </IMG>

Code (gambas)

  1. ' Gambas class file
  2.  
  3. ''Run this code in a Graphical application
  4.  
  5. Private Gridview1 As Gridview
  6.  
  7. Public Sub Form_Open()
  8.  
  9.   Dim sHeader As String[] = ["ID", "#Name", "Phone", "Gender", "Weight"]
  10.   Dim sData As String[] = ["6088", "Blake the Man", "907-555-1212", "M", "177"]
  11.   Dim iCol As Integer
  12.  
  13.   BuildForm()
  14.  
  15.   GridView1.Columns.count = sHeader.Count + 1
  16.   For iCol = 0 To sHeader.Max
  17.     GridView1.Columns[iCol].Title = sHeader[iCol]
  18.     GridView1.Columns[iCol].Alignment = Align.Center
  19.     GridView1.Font.Bold = True
  20.   Next
  21.  
  22.   For iCol = 0 To sData.Max
  23.     With GridView1
  24.       .Rows.Count = 1
  25.       .[0, iCol].Padding = 3
  26.       .[0, iCol].Text = sData[iCol]
  27.       .[0, iCol].Alignment = Align.Center
  28.       .[0, iCol].Font = Font["ubuntu,italic,14"]
  29.       .[0, iCol].Font.Bold = True
  30.       .[0, iCol].Foreground = Color.Red
  31.     End With
  32.   Next
  33.  
  34.   GridView1.Columns.Width = -1
  35.  
  36.  
  37. Public Sub BuildForm()
  38.  
  39.   .Height = 80
  40.   .Width = 450
  41.   .Arrangement = Arrange.Vertical
  42.   .Padding = 5
  43.  
  44. With Gridview1 = New GridView(Me) As "Gridview1"
  45.   .Expand = True
  46.   .Grid = False
  47.   .Header = GridView.Horizontal
  48.  
  49.  


A little tweaking and this worked out fine.
Online now: No Back to the top
1 guest and 0 members have just viewed this.