其他分享
首页 > 其他分享> > ComboBox1 绑定手动创建的DataTable

ComboBox1 绑定手动创建的DataTable

作者:互联网

 

'**************************************************
'*过程名称:DT_PAFORMAL
'*功能说明:员工类别
'**************************************************
Public Function DT_PAFORMAL() As DataTable
Dim dt As New DataTable
Dim dc1 As DataColumn = New DataColumn("id", Type.GetType("System.String"))
Dim dc2 As DataColumn = New DataColumn("name", Type.GetType("System.String"))
dt.Columns.Add(dc1)
dt.Columns.Add(dc2)
Dim dr1 As DataRow = dt.NewRow()
dr1("id") = "1"
dr1("name") = "干部"
dt.Rows.Add(dr1)
Dim dr2 As DataRow = dt.NewRow()
dr2("id") = "2"
dr2("name") = "固定工"
dt.Rows.Add(dr2)
Dim dr3 As DataRow = dt.NewRow()
dr3("id") = "3"
dr3("name") = "合同工"
dt.Rows.Add(dr3)
Dim dr4 As DataRow = dt.NewRow()
dr4("id") = "4"
dr4("name") = "临时工"
dt.Rows.Add(dr4)
Dim dr5 As DataRow = dt.NewRow()
dr5("id") = "5"
dr5("name") = "外来务工"
dt.Rows.Add(dr5)
Return dt
End Function

 

'调用

CMB_PAFORMAL.DataSource = CL.DT_PAFORMAL.Copy
CMB_PAFORMAL.DisplayMember = "name"
CMB_PAFORMAL.ValueMember = "id"
CMB_PAFORMAL.SelectedIndex = -1

标签:Dim,PAFORMAL,name,绑定,id,Add,dt,ComboBox1,DataTable
来源: https://www.cnblogs.com/beichengshiqiao/p/16663125.html