當前位置:成語大全網 - 書法字典 - VB.NET的Combobox數據綁定

VB.NET的Combobox數據綁定

使用SelectedIndexChanged事件。

private Sub cbxBigDept _ selectedindex changed(ByVal sender As System。對象,ByVal e作為系統。EventArgs)處理ComboBox1。SelectedIndexChanged

將strBM標註為字符串

StrBM = cbxbigdept . selected value‘獲取當前部門名稱。

dim my conn as SqlConnection = new SqlConnection(“……。。。“)

我的兒子。打開()

Dim myCmd as string =“從小型部門表中選擇小型部門,其中大型部門=““&;strBM & amp"

dim my adapter as sqldata adapter = new sqldata adapter(myCmd,myConn)

將我的數據集設為數據集=新數據集

我的適配器。填充(我的數據集)

me . cbx sondept . data source = my adapter。表(0)

Me.cbxSonDept.ValueMember =“小型部門“

我的兒子。關閉

末端接頭

祝妳成功!