如题,C#的checkedlistbox没有displaymember和valuemember这些函数,如何绑定其value和text呢?
请高手明示,越详细越好,在下新手,谢谢!

解决方案 »

  1.   

    CheckedListBox没有真正/完全支持数据绑定:
    [url=http://support.microsoft.com/default.aspx/kb/327896]...CheckedListBox was not designed for data binding...[url]CheckedListBox的DataSource在Intelisense中看不到,但可以被赋值(CheckedListBox继承于ListBox,ListBox可以绑定)。但明显功能有限。解决方法就是写一个自定义控件(比较难),或手动显示数据(见上述引用中的例子)。
      

  2.   


    明示,我现在希望checkedlistbox的value和text分别绑定一个整形数组和字符串数组,datamembet,valuemember还有datasource应该怎么添加,我直接写好像不太对。
    使得我选择某一项(text)返回它对应值(value).
    多谢!!
      

  3.   


    什么意思?
    我在网上也搜过一些方法,绑定了数据源datasource时候,value和text就没什么问题了。但是我只是一个基本选择显示,不连接数据库,这个datasource应该怎么设置,我就不明白了。指点啊~~
      

  4.   

    void s_checkedlistbox_bind()
            {
                string tmp_sql = "select * from title order by id desc";
                apter = new OleDbDataAdapter(tmp_sql, conn);
                dt = new DataTable();
                ds = new DataSet();
                apter.Fill(dt);
                apter.Fill(ds);
                checkedListBox1.DataSource = dt;
                checkedListBox1.DisplayMember = "title"; //要显示的属性名
                checkedListBox1.ValueMember = "id"; 
                 
            }