如何将数据值添加到我的组合框中 [英] How Do I Add Data Value To My Combo Box

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

问题描述

如何在我的组合框中添加数据值?因为我对文本不感兴趣该文本仅供用户查看,但数据值是wat我要指定MYSELF。如何完成GUYS ????我正在使用VB。 VISUAL STUDIO 2013.感谢你

how do i add the DATA VALUE in my combo box? because i am not interested in the text. the text is just for user to see but the DATA VALUE is wat i want to specify MYSELF. HOW IS THAT DONE GUYS???? I AM USING VB. VISUAL STUDIO 2013. Thank u

推荐答案

阅读文档 [ ^ ]将告诉你如何操作。
Reading the documentation[^] will show you how to do it.


这里是示例代码。请试试这个。



Here is sample code. please try this.

   class MyClass
        {
            public string Data { get; set; }
            public string Value { get; set; }
        }

        private void BindData()
        {
            ComboBox yourComboBox = new ComboBox();

            List<myclass> obj = new List<myclass>();
            for (int i = 0; i < 5; i++)
            {
                obj.Add(new MyClass() { Data = "Data" + i, Value = (i * 5).ToString() });
            }

            yourComboBox.DisplayMember = "Data";
            yourComboBox.ValueMember = "Value";
            yourComboBox.DataSource = obj;
        }
</myclass></myclass>





工作正常我已经测试过...

如果有任何混淆让我知道。



it is working fine i have tested...
if any confusion let me know.


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

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