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
|