Hi Everyone,
I have been working on my small project and I think I could do with some guidance
what I have at the moment is this
when something is added to the listbox and this is fine but when I add something that has 2 lines in it i get this
how do I get it so it displays right also how do I have it always with the blue Line? ( like below)
Listbox advice
Re: Listbox advice
Hello Andy,
The problem you're having with the display of the text in your second image is: the text string that's been scanned into your ListBox contains an ASCII code for either a carriage return (gb.Cr) or a line feed (gb.Lf). Perhaps even both (gb.CrLf). This crams two lines of text into a vertical space designed for only one line of text.
I'd use the Replace() function, which will clean any of those three ASCII codes from the text string if they're present (because we don't know which one it is), allowing it all to be on the same line, separated by a dash character.
In my code example below, I'll clean any of those ASCII codes from the text already present at index zero in the ListBox. But its always better to clean these codes from the source string, before it gets assigned to the ListBox. Depending on how your code works, it may simple. Or it may be simpler to fix what's already in the ListBox.
Here's the code:
I hope this helps. Good luck,
Godzilla
The problem you're having with the display of the text in your second image is: the text string that's been scanned into your ListBox contains an ASCII code for either a carriage return (gb.Cr) or a line feed (gb.Lf). Perhaps even both (gb.CrLf). This crams two lines of text into a vertical space designed for only one line of text.
I'd use the Replace() function, which will clean any of those three ASCII codes from the text string if they're present (because we don't know which one it is), allowing it all to be on the same line, separated by a dash character.
In my code example below, I'll clean any of those ASCII codes from the text already present at index zero in the ListBox. But its always better to clean these codes from the source string, before it gets assigned to the ListBox. Depending on how your code works, it may simple. Or it may be simpler to fix what's already in the ListBox.
Here's the code:
ListBox1[0].Text = Replace(ListBox1[0].Text, gb.Cr, " - ")
ListBox1[0].Text = Replace(ListBox1[0].Text, gb.Lf, " - ")
ListBox1[0].Text = Replace(ListBox1[0].Text, gb.CrLf, " - ")
ListBox1[0].Selected = True
This code will also select that same line, giving it the blue line you wanted. To allow multiple lines in the ListBox to be selected, I believe you'll need to set its "Mode" option to "Multiple", otherwise leave it on "Single". I hope this helps. Good luck,
Godzilla
-
- Posts: 363
- Joined: Wednesday 2nd December 2020 12:11am
- Location: Northampton, England
- Contact:
Re: Listbox advice
Hi Godzilla,
Thank-you for the information that help the problem is the 2 lines should be displayed (i am adding the Crlf myself. how would i widen the area so it displays correctly?
i would need it to show
CADBURYS CREAM EGG
5 @ £0.50
Sorry maybe I did not explain what I wanted clearly (it was 2am when I typed that post)
Thank-you for the information that help the problem is the 2 lines should be displayed (i am adding the Crlf myself. how would i widen the area so it displays correctly?
i would need it to show
CADBURYS CREAM EGG
5 @ £0.50
Sorry maybe I did not explain what I wanted clearly (it was 2am when I typed that post)
-
- Posts: 363
- Joined: Wednesday 2nd December 2020 12:11am
- Location: Northampton, England
- Contact:
Re: Listbox advice
i have tried all the other interfaces before I have even tried to use a group of labels for the display but that looked even worse.
I have had good feed back from customers who say the Listbox is the best for them when they are using the software
The 2 or more line description is only ever used on qty or price override modes so they are not very often used.
I am open to advice though all my other window applications use the list box to display product data (as the list box is used to populate the printed receipt (on the windows version) so if a item is removed / voided it will not print on the receipt
I have had good feed back from customers who say the Listbox is the best for them when they are using the software
The 2 or more line description is only ever used on qty or price override modes so they are not very often used.
I am open to advice though all my other window applications use the list box to display product data (as the list box is used to populate the printed receipt (on the windows version) so if a item is removed / voided it will not print on the receipt
Re: Listbox advice
I'm sorry, I really don't understand what you are saying. The end user will be unaware of the type of control you are using; they are only interested in its appearance and usability.
The point about using (say) a TableView is that you can control the cell height and therefore include multiple lines of text without the text being cropped. My example didn't show the grid lines, but obviously these can be turned on or off.
I didn't include any of my code because it was so horrible, but I displayed multi-lines like this:-
TableView1[0, 0].Text = "Cadbury Cream Eggs" & gb.Lf & Space(4) & "5 @ £0.50"
If you wanted to keep the Item separate from the cost, then the second example does this; TableView1[0, 0].Text = "Item"
TableView1[0, 1].Text = "Cost"
TableView1[1, 0].Text = "Cadbury Cream Eggs"
TableView1[1, 1].Text = "5 @ £0.50"
TableView1[2, 0].Text = "Orange Juice - Value"
TableView1[2, 0].Text = "1l @ £1.50"
...but I'm probably missing your point.