Adding data to a existing line in a list box

Post your Gambas programming questions here.
Post Reply
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Adding data to a existing line in a list box

Post by AndyGable »

Hi all,

Can some one please point me in the correct direction

I want to know how can I add another line of text to an existing line with in a list box?

Example

I have in my list box

Value orange juice £0.50

I want to apply a 50% discount so when I do it should look like this in the list box

Value orange juice £0.50
Discount -£0.25

So the whole line is selected with the blue high lighter


Or do I have to remove the line completely and re add both lines?
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Adding data to a existing line in a list box

Post by BruceSteers »

I'm pretty sure a listview won't use varying line sizes

But a gridview will for sure
You can set gridview.rows[iIndex].Height = gridview.font.height * 2 or something
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Adding data to a existing line in a list box

Post by BruceSteers »

BruceSteers wrote: Tuesday 11th October 2022 8:36pm I'm pretty sure a listview won't use varying line sizes

But a gridview will for sure
You can set gridview.rows[iIndex].Height = gridview.font.height * 2 or something
I could be wrong

Did you try ...

Listview1[iIndex].Text &= "/nDiscount -£0.25"
Last edited by BruceSteers on Wednesday 12th October 2022 2:36pm, edited 1 time in total.
If at first you don't succeed , try doing something differently.
BruceS
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Adding data to a existing line in a list box

Post by AndyGable »

I managed to get it to work thanks

I used

Code: Select all

Dim he as gridview
Dim b as byte

B  = lstcurrent.list.max

Listcurrent[b].text = gb.crlf & "Discount"

gw = lstcurrent.children[0]

gw.rows[b].height = -1

Listcurrent.refresh
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Adding data to a existing line in a list box

Post by BruceSteers »

I found it just works as expected putting in a new line in a listbox as normal, no need to set any sizes it's handled automatically.
(sorry i was at work last night so was guessing)
I tried it today...

Listcurrent[ b ].text &= "\nDiscount"

should be all you need :)
If at first you don't succeed , try doing something differently.
BruceS
Post Reply