vb.net ComboBox 绑定数据字段

前端之家收集整理的这篇文章主要介绍了vb.net ComboBox 绑定数据字段前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Dim dt As DataTable = Nothing
ComMain.objDBCon = New ComDBConn
dt = ComMain.objDBCon.PFn_QueryDB(Fn_GetTblInfosql)

‘指定值=sql指定字段
Me.ComboBox1.ValueMember = "ROW_ID"

’指定显示列=sql指定字段
Me.ComboBox1.DisplayMember = "TABLE_ID"

‘绑定DataTable

Me.ComboBox1.DataSource = dt

sql:

SELECT ROW_NUMBER() OVER(ORDER BY B.NAME) AS 'ROW_ID',B.NAME AS TABLE_ID FROM SYSOBJECTS B WHERE B.XTYPE = 'U' ORDER BY B.NAME

猜你在找的VB相关文章