[Sloved] Change Listbox list size

Post your Gambas programming questions here.
AndyGable
Posts: 137
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

[Sloved] Change Listbox list size

Post by AndyGable » Saturday 03rd July 2021 9:03pm

Hi Everyone,

Can someone show me please how I can display 2 line to in a List box?

I can do the Chr(10) & chr(13) but when it is added to the list some of the top and bottom of the text is missing (it looks like the list section has not expanded enough to allow the 2 lines see example)

Image
Last edited by AndyGable on Monday 05th July 2021 3:39pm, edited 1 time in total.

vuott
Posts: 97
Joined: Wednesday 05th April 2017 6:07pm
Location: European Union

Re: Change Listbox list size

Post by vuott » Saturday 03rd July 2021 11:39pm

I suggest this page from italian wiki:

https://www.gambas-it.org/wiki/index.ph ... e_per_item

AndyGable
Posts: 137
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Re: Change Listbox list size

Post by AndyGable » Sunday 04th July 2021 2:17am

Thanks @vuott I shall try that in the morning.

AndyGable
Posts: 137
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Re: Change Listbox list size

Post by AndyGable » Sunday 04th July 2021 2:35pm

Hi Everyone,

Thank-you to everyone who has given me advice on this issues

Image

As you can see it works perfectly now

All I need to do is work out how to have spaces working

example

Dataline 1______________________________Message
Dataline 2
Dataline 3 This is longer __________________Message

the __ is the number of spaces needed to align the Message section

User avatar
grayghost4
Posts: 119
Joined: Wednesday 05th December 2018 5:00am
Location: Marengo, illinois usa

Re: Change Listbox list size

Post by grayghost4 » Sunday 04th July 2021 7:08pm

   
sitem#1 = "Amount"    
sitem#2 = "102.65"
 sItem#1 & Space(30 - Len(sItem#1)) &  sItem#2"]

AndyGable
Posts: 137
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Re: Change Listbox list size

Post by AndyGable » Sunday 04th July 2021 9:12pm

grayghost4 wrote:
Sunday 04th July 2021 7:08pm
   
sitem#1 = "Amount"    
sitem#2 = "102.65"
 sItem#1 & Space(30 - Len(sItem#1)) &  sItem#2"]
Thanks grayghost4 do I need to change the font to a mono spaced one for that to work?

User avatar
Quincunxian
Posts: 132
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: Change Listbox list size

Post by Quincunxian » Sunday 04th July 2021 10:06pm

You can also use :
String.PadRight(sItem#1, 30, " ") &  sItem#2"
Returns a new string that left-aligns the characters in the original string by padding them on the right with a specified string pattern, for a specified total length.
  • String is the string to pad.
    Length is the final length in UTF-8 characters.
    Pad is the string pattern used for padding. By default, a space is used.
See also: String.PadLeft
Cheers - Quin.
I code therefore I am

vuott
Posts: 97
Joined: Wednesday 05th April 2017 6:07pm
Location: European Union

Re: Change Listbox list size

Post by vuott » Sunday 04th July 2021 11:21pm

... and if you like the thrill of external functions: :D
' int printf (const char *__restrict __format, ...)
' Write formatted output to stdout.
Private Extern printf(__format As String, arg1 As String, arg2 As String) As Integer In "libc:6"


Public Sub Main()
 
  printf("%-30s%1s\n", "Dataline 1", "Message...")
  printf("%-30s%1s\n", "Dataline 2", "Message...")
  printf("%-30s%1s", "Dataline 3 This is longer", "Message...")
 
End

User avatar
BruceSteers
Posts: 652
Joined: Thursday 23rd July 2020 5:20pm

Re: Change Listbox list size

Post by BruceSteers » Monday 05th July 2021 8:59am

AndyGable wrote:
Sunday 04th July 2021 9:12pm
grayghost4 wrote:
Sunday 04th July 2021 7:08pm
   
sitem#1 = "Amount"    
sitem#2 = "102.65"
 sItem#1 & Space(30 - Len(sItem#1)) &  sItem#2"]
Thanks grayghost4 do I need to change the font to a mono spaced one for that to work?
do you know how quick it would be to try it for yourself and see?

;)
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
grayghost4
Posts: 119
Joined: Wednesday 05th December 2018 5:00am
Location: Marengo, illinois usa

Re: Change Listbox list size

Post by grayghost4 » Monday 05th July 2021 3:17pm

do you know how quick it would be to try it for yourself and see?
I had a long post typed up in response to his post..... about strings or numbers and weather the numbers had decimals in them and weather the strings had multiple lines and weather posting to the screen or a printer that used postscript or a simple POS printer and several other things that I can't remember now ...

and it ended with "Trial and Error"

and then I deleted it .... anyone posting here should have enough experience with programing that I don't need to tell them any of that :lol:

PS. and I may return and delete this post also :D

Post Reply