Avatar of grazhull
grazhull
 asked on

C# Listbox help

Hi,

Im creating a till system with c#, which im not amazingly familar with.  What i want to happen with a push of a button is the name and a $ value to be sent to the list box wth the total $ value to be added up in a seperate box, I would also like to be able to delete the line out of the list box and the value to be removed from the 'running total'

I cant seem to figure out how to use values with ListBox, or if there would be a better system to use for this.  Any help would be greatly appreciated.

Thanks
C#

Avatar of undefined
Last Comment
grazhull

8/22/2022 - Mon
rockiroads

rockiroads

how are you wanting to populate the listbox
grazhull

ASKER
Just line by line, like you would see on well a till :P so far ive just added to it with

 TillDisplay.Items.Add(button1.Text + itemprice[1]);

but when i delete the line            

 TillDisplay.Items.Remove(TillDisplay.SelectedItem);

my total wont get updated, because i add it up seperatly which is why im trying to work out how to assign a value to the line im adding then i can just add up the value of each line and if a line gets removed that value will be taken away!?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
rockiroads

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
rockiroads

Ive been looking here which contains samples for various things http://msdn.microsoft.com/en-us/library/6dwb14tw.aspx
SOLUTION
rockiroads

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
rockiroads

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
grazhull

ASKER
with subitems.add it requires a string, is there anyway it can be made to use say a float?
rockiroads

use tostring eg
float a = 20
....add (  a.ToString());
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
grazhull

ASKER
Great Help! Thanks!