如何为组合框赋值并添加它 [英] How do I give value to combobox and add it

查看:154
本文介绍了如何为组合框赋值并添加它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我想要做的是,如果我在C#中有2个或更多的组合框,并且让我们说每个中有3个值(单词)我想添加就像我选择opcion 0 = 10选项1 = 5,选项2 = 0;对于组合框2相同



并想在标签中显示答案



这是我到目前为止所拥有的...



So, what im trying to do is, if i have 2 or more comboboxes in C# and lets say each have 3 values in it (words) i want to add like if i select opcion 0 = 10 opction 1 = 5, option 2 = 0; same for combobox 2

and want to display answer in label

this is what i have so far...

private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox5.SelectedIndex)
            {
                case 0:
                    cntbth = 10;
                    break;
                case 1:
                    cntbth = 5;
                    break;
                case 2:
                    cntbth = 0;
                    break;
            }

            label13.Text = cntbth.ToString();
        }

        private void comboBox6_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox5.SelectedIndex)
            {
                case 0:
                    cntbth = 10;
                    break;
                case 1:
                    cntbth = 5;
                    break;
                case 2:
                    cntbth = 0;
                    break;
            }

            label13.Text = cntbth.ToString();
        }





cntbt和INT(全局)有什么建议?



cntbt is and INT (global) any suggestions?

推荐答案

看看这两个链接,希望对你有所帮助:

http://stackoverflow.com/questions/12711521/how-to-add-value-to-comboboxs-items-so- i-can-like-like-like-combobox-sele [ ^ ]



http://stackoverflow.com / questions / 15780523 / how-add-itemstext-value-to-combobox-read-them-in-selectedindexchanged-sel [ ^ ]
Look at this two links, hope helpful:
http://stackoverflow.com/questions/12711521/how-to-add-value-to-comboboxs-items-so-i-can-choose-it-like-this-combobox-sele[^]

http://stackoverflow.com/questions/15780523/how-add-itemstext-value-to-combobox-read-them-in-selectedindexchanged-sel[^]


这篇关于如何为组合框赋值并添加它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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