Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2007, 08:42 AM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zachatcoza
Default get current checkedlistbox value

i would like to go through a checkedlistbox and get the current cheked item, but i only get the value from my first checked item. Can any one help me with this please?

//(The Code Is As Follows)
for (int i = 0; i < checkedListBox2.CheckedItems.Count; i++)
                    {
                        foreach (DataRow myDataRow in myDataSet.Tables["Toppings"].Rows)
                        {


                            if (myDataRow["Product"].ToString() == "N/A")
                            {
                                if (myDataRow["Catagory"].ToString() == pSize)
                                {
                                    if (myDataRow["Topping"].ToString() == checkedListBox2.Items[i].ToString())
                                    {

                                        //comboBox1.Items.Add(myDataRow["Product"].ToString());
                                        //checkedListBox1.Items.Add(myDataRow["Product"].ToString());
                                        string tTotal = (myDataRow["Price"]).ToString();
                                        tPrice = double.Parse(tTotal);
                                        ttPrice = ttPrice + tPrice;
                                    }
                                }


                            }
                        }
                    }
                    textBox2.Text = string.Format("{0:#,#.00}", ttPrice);
.............................................
Let say item 1 is 5.00
item 2 is 10.00
item 3 is 15.00

if i select only one item,
Textbox 2 only gives me 5.00

 if i select item 1 and 2 i get 10.00 witch is only item 1+1

when i select all three items, i get 30.00 witch is what i want.

Please help me






Similar Threads
Thread Thread Starter Forum Replies Last Post
checkedListBox to a listbox? silasla C# 4 May 2nd, 2008 04:31 AM
current cell darkhalf Excel VBA 2 June 26th, 2006 01:56 PM
Getting the current month Regornil JSP Basics 1 July 19th, 2004 09:01 PM
CheckedListBox control and Database M3L C# 1 May 26th, 2004 11:50 PM
make checkedListBox readonly melvik C# 0 September 14th, 2003 09:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.