打开工具栏的工程,选择部件, 然后再对话框中microsoft ado data control 6.0前打勾后确定就行了
添加ado,connectionstring属性设置Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db_kfgl.mdb;Persist Security Info=False
recordsource 设置表 kf
DataCombo1组合框属性设置 rowsource Adodc1 listfield 房间号 boundcolumn设置房间号
Private Sub DataCombo1_Click(Area As Integer)
Adodc2.RecordSource = "kf where 房间号='" + DataCombo1 + "'"
Adodc2.Refresh
With Adodc2.Recordset
If .RecordCount > 0 Then
For i = 0 To .Fields.Count - 1
If .Fields(i).Value <> "" Then
Text1(i).Text = .Fields(i).Value
Else
Text1(i).Text = ""
End If
Next i
End If
End With
End Sub
combobox和datacombo区别于选择
用DATACOMBO,其是绑定的,速度快,COMBOX需要你自己一条条里面加,速度慢。
combobox的按钮有空也找一个研究下,看下跟datacombo的使用区别
combobox datafield的作用
Private Sub Command1_Click()
MsgBox DataCombo1.SelectedItem
End Sub
DataCombo和DataList控件的使用方法是很简单的,便于快速的应用开发。关于这两个控件的其他详细信息,可以参考MSDN Library中的详细说明。