CheckedListBoxes有一个重要问题 [英] Having an important problem with CheckedListBoxes

查看:73
本文介绍了CheckedListBoxes有一个重要问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在做一个项目,我在使用选中的列表框时遇到问题.我在选中的列表框中插入了5个项目,并已将所有项目的价格放入数组中.(10,20,30,40,50)相应地.我要这个

*当用户单击item1时,实际价格为10 $
*当用户单击item2时,实际价格为30美元(1和2两者)
*当用户重新单击item1时,实际价格为20美元(仅单击第二个项目)

等等.

Hello everyone,

I am working on a project an I have a problem with using checked list boxes. I have 5 items which were inserted in a checked listboxes and I have put in an array all the items prices.(10,20,30,40,50) accordingly. I want this;

* When user clicked item1 the actual price will be 10 $
* When user clicked item2 the actual price will be 30 $(Both 1 and 2)
* When user Re-clicked item1 the actual price will be 20 $(Just second item clicked)

and so on.

if (checkedListBoxAdditions.CheckedItems.Count != 0)
   {
   string s = "";
            for (int x = 0; x <= checkedListBoxAdditions.CheckedItems.Count - 1; x++)
     {
         if (checkedListBoxAdditions. == true)
         {
             totalAmount = totalAmount + price[4];
         }
         if (x == 2)
         {
             totalAmount = totalAmount + price[5];
         }
         if (x == 3)
         {
             totalAmount = totalAmount + price[6];
         }
         if (x == 4)
         {
             totalAmount = totalAmount + price[7];
         }
         if (x == 5)
         {
             totalAmount = totalAmount + price[8];
         }

     }
            MessageBox.Show(totalAmount + "");


   }


这是我尝试过的代码.我真的需要帮助.
谢谢大家.


Here is the code that I tried. I really need help.
Thanks everyone.

推荐答案


*当用户单击item2时,实际价格为30

* When user clicked item2 the actual price will be 30


(1和2均是)
*当用户重新单击item1时,实际价格为20
(Both 1 and 2)
* When user Re-clicked item1 the actual price will be 20


(仅单击第二项)

等等.

(Just second item clicked)

and so on.

if (checkedListBoxAdditions.CheckedItems.Count != 0)
   {
   string s = "";
            for (int x = 0; x <= checkedListBoxAdditions.CheckedItems.Count - 1; x++)
     {
         if (checkedListBoxAdditions. == true)
         {
             totalAmount = totalAmount + price[4];
         }
         if (x == 2)
         {
             totalAmount = totalAmount + price[5];
         }
         if (x == 3)
         {
             totalAmount = totalAmount + price[6];
         }
         if (x == 4)
         {
             totalAmount = totalAmount + price[7];
         }
         if (x == 5)
         {
             totalAmount = totalAmount + price[8];
         }

     }
            MessageBox.Show(totalAmount + "");


   }


这是我尝试过的代码.我真的需要帮助.
谢谢大家.


Here is the code that I tried. I really need help.
Thanks everyone.


这篇关于CheckedListBoxes有一个重要问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆