vb.net中combobox与数组绑定

        Dim lbstr() As String = {"集团文件", "红头文件", "各店通知", "学习资料", "常用文件"}
        Dim lbvalue() As String = {"集团通知", "红头文件", "各店通知", "学习资料", "常用资料"}
        Dim dt As New DataTable
        dt.Columns.Add("名称")
        dt.Columns.Add("值")
        cmb_lb.Items.Clear()
        Dim i As Integer = 0
        For i = 0 To lbstr.Length - 1
            Dim arow As DataRow = dt.NewRow
            arow(0) = lbstr(i).ToString
            arow(1) = lbvalue(i).ToString
            dt.Rows.Add(arow)
        Next
        cmb_lb.DataSource = dt
        cmb_lb.DisplayMember = "名称"
        cmb_lb.ValueMember = "值"
两个数组一个存内容一个存值,然后读入到datatable,最后combobx的数据源设定为datatable就可以了.

你可能感兴趣的:(个性天空,vb.net,integer,string)