text alignment

tremara1

Active Member
Licensed User
Longtime User
Hi, and Happy Holidays to all. I was wondering if anyone had a solution to aligning text in textbox as columns. I have tried a couple of solutions I found in the forum. It seems the problem I have is the fact characters have different width. ( ooo is phsically wider than iii ) I have tried the richTextbox dll indenting but it seems to indent all elements that is if you set left indent to 0 for the first element then set left indent to 20 for the second element it indents both elements to 20. One solution I looked at saved the data to a formatted file and it looked perfect but when I applied this to display in a textbox.....same problem. I have a simple example of my problem.
Thanks...
Tremara1 Australia
 

Attachments

  • textBoxAlign.sbp
    885 bytes · Views: 153

taximania

Well-Known Member
Licensed User
Longtime User
This line confused me.
B4X:
CallSub("makeSpace",35 - StrLength("first"))

The CallSub isn't needed is it ?
B4X:
makeSpace(35 - StrLength("first"))

This works
B4X:
makeSpace(35 - 5)
StrLength("first")) has a fixed value, 5

Or even
B4X:
makeSpace(30)

My reply doesn't help the OP much.
But perhaps he was confused about calling subs as well.

Using the same fixed value in both calls to makespace(30) in the example
program provided does align the words correctly. But doesn't touch
the font pitch.

Is there a way to show text, in a fixed pitch, in a textbox ?
Was probably a better question.


Hic, Hey, come on it's xmas :)
 

tremara1

Active Member
Licensed User
Longtime User
sorry about the confusion

The reason I used a call to a sub was I want to use this to populate a textbox with formatted data from database fields of varying lengths of data.( ie firstname secondname). The length of the data will be highly variable. I think your right it is the pitch I need to control...any clues?

thanks Tremara1
Australia
 

taximania

Well-Known Member
Licensed User
Longtime User
Is this any help, Courier is a fixed pitch font :)

fl is a FormLib object

B4X:
Sub Globals
   'Declare the global variables here.

End Sub

Sub App_Start
   Form1.Show
   fl.New1("Form1",B4PObject(1))
   Msgbox("standard text")
   fl.ChangeFont("TextBox1","Ariel")
   textbox1.Text=textbox1.Text &  CRLF & "iiiiiii1"
   textbox1.Text=textbox1.Text &  CRLF & "WWWWWWWW"
   Msgbox("Ariel")
   fl.ChangeFont("TextBox1","Courier New")
   textbox1.Text=textbox1.Text &  CRLF & "iiiiiii1"
   textbox1.Text=textbox1.Text &  CRLF & "WWWWWWWW"
   Msgbox("Courier")
   
End Sub

Edit: Tested on device too ;-)
 
Last edited:

tremara1

Active Member
Licensed User
Longtime User
done !!!!

Thanks mate........it worked a treat.

Tremara1
Australia
 

Colin123

New Member
txtReport.Text = txtReport.Text & "test" & cTab & "qwe" & CRLF
txtReport.Text = txtReport.Text & "t" & cTab & "asd" & CRLF
 
Top