listbox

how to use listbox

Page 1 of 1

6 Replies - 1259 Views - Last Post: 12 November 2010 - 05:16 AM Rate Topic: -----

#1 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

listbox

Posted 10 November 2010 - 02:53 PM

Hi all i was wondering could anyone point me in the right direction of a good tutorial of code snippet on how to use listboxes

i am write a c# windows form.

i have 8 items in my list box each item cost 2.50 each, and a users can select several item then i have to be able to calculate the total prices for the users selections.

any help would be great.
Is This A Good Question/Topic? 0
  • +

Replies To: listbox

#2 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5467
  • View blog
  • Posts: 11,745
  • Joined: 02-June 10

Re: listbox

Posted 10 November 2010 - 02:57 PM

http://www.google.co...=UTF-8&oe=UTF-8

Googleing for "MSDN" plus your area of interest will take you right to it
Was This Post Helpful? 1
  • +
  • -

#3 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

Re: listbox

Posted 10 November 2010 - 03:01 PM

while you are on looking at this do you know of any good code snippets aswell please
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5467
  • View blog
  • Posts: 11,745
  • Joined: 02-June 10

Re: listbox

Posted 10 November 2010 - 03:18 PM

Did you look at any of the links on the Google response?
The MSDN pages have code examples on them.
http://msdn.microsof...ls.listbox.aspx

You haven't shown any good faith effort to code any of this.
You haven't really described what you're having trouble with: Adding an item to a listbox, getting the user selection, doing the math...

Just "can you help me with a list box and doing some math"...

When you can better define what you are having trouble with, please show us the code you wrote that is giving you grief and we'll try to get you on the right path.
Was This Post Helpful? 0
  • +
  • -

#5 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: listbox

Posted 10 November 2010 - 04:29 PM

Even better than MSDN: http://dotnetperls.com/listbox
Was This Post Helpful? 0
  • +
  • -

#6 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

Re: listbox

Posted 12 November 2010 - 04:51 AM

thanks all got my code sorted that all for help any go sites that i could look at for calculating checked boxes and list boxes together you like this

if checkboxe1. checked

and listbox1.selected

give total cost

that sort of thing

o yeah this is the code i wrote for the problem i was haveing above any suggestion on improving

namespace DVD
{
    public partial class frmDVD : Form
    {
        public frmDVD()
        {
            InitializeComponent();
            IBXDvD.SelectionMode = SelectionMode.MultiExtended;
            IBXDvD.Items.Add("Rambo");
            IBXDvD.Items.Add("Saw 3D");
            IBXDvD.Items.Add("Hurt Locker");
            IBXDvD.Items.Add("Road Trip");
            IBXDvD.Items.Add("Leon");
            IBXDvD.Items.Add("Iron Eagle");
            IBXDvD.Items.Add("Goodfellas");
            IBXDvD.Items.Add("Matrix");
        }

        private void btnRent_Click(object sender, EventArgs e)
        {
            double selections,dvds;
            selections = IBXDvD.SelectedItems.Count;
            dvds= selections * 2.50;
            lblPrice.Text=("The Price for the dvds you have selected is " +"" + dvds.ToString("##0.00"));
        }

    }
}

Was This Post Helpful? 0
  • +
  • -

#7 batesy3k  Icon User is offline

  • D.I.C Regular

Reputation: 41
  • View blog
  • Posts: 299
  • Joined: 10-September 09

Re: listbox

Posted 12 November 2010 - 05:16 AM

Looks like 2 people are doing the same thing? possibly assignment work...

I gave an example of how to do this in the previous thread:

http://www.dreaminco...199644-listbox/

private void button1_Click(object sender, EventArgs e)
{
    // initialise total to zero
    double total = 0;

    // are there selected items?
    if (listBox1.SelectedItems.Count > 0)
    {
        // calculate total
        total = listBox1.SelectedItems.Count * 2.50;
    }

    // output example
    this.Text = "£" + total.ToString();
}



Regards :)

This post has been edited by batesy3k: 12 November 2010 - 05:17 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1