如何将数据值添加到我的组合框中

问题描述:

如何在我的组合框中添加数据值?因为我对文本不感兴趣该文本仅供用户查看,但数据值是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.