vb中如何将两个组合框中的多项内容进行绑定?急需解答!!! 35
比如我新建了两个combobox.在combobox1中有专业和民族两个字段,当我选中专业时,在combobox2中则会自动显示出英语,数学,物理等多个选项。当我在选中c...
比如我新建了两个combobox.在combobox1中有专业和民族两个字段,当我选中专业时,在combobox2中则会自动显示出英语,数学,物理等多个选项。当我在选中combobox1中的民族时则在combobox2中会显示出汉族,满族等相应字段.请高手帮忙!!希望尽量详细些,谢谢!!
那请问vb中如何将combobox2中的数据同数据库进行绑定呢?比如我选择了英语,则在相应的msflexgrid控件中会显示相应的记录,同时在设计的文本框中也会同步显示相关信息?请尽量详细些,谢谢!!(我是用vb+access) 展开
那请问vb中如何将combobox2中的数据同数据库进行绑定呢?比如我选择了英语,则在相应的msflexgrid控件中会显示相应的记录,同时在设计的文本框中也会同步显示相关信息?请尽量详细些,谢谢!!(我是用vb+access) 展开
展开全部
Option Explicit
Private Sub Combo1_Click()
If Combo1.Text = "专业" Then
Combo2.Clear
Combo2.AddItem "英语"
Combo2.AddItem "数学"
Combo2.AddItem "物理"
ElseIf Combo1.Text = "民族" Then
Combo2.Clear
Combo2.AddItem "满族"
Combo2.AddItem "汉族"
Combo2.AddItem "回族"
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "专业"
Combo1.AddItem "民族"
End Sub
Private Sub Combo1_Click()
If Combo1.Text = "专业" Then
Combo2.Clear
Combo2.AddItem "英语"
Combo2.AddItem "数学"
Combo2.AddItem "物理"
ElseIf Combo1.Text = "民族" Then
Combo2.Clear
Combo2.AddItem "满族"
Combo2.AddItem "汉族"
Combo2.AddItem "回族"
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "专业"
Combo1.AddItem "民族"
End Sub
展开全部
用combobox的Click() 事件,
sql = "select * from "表名" where "字段名"= & combobox2
Set myrs1 = mydata.OpenRecordset(sql)
这时myrs1就是你想要数据的集合,再进行写入到msflexgrid
If myrs1.EOF = False Then
myrs1.MoveFirst
Do While Not myrs1.EOF
z = z + 1
myrs1.MoveNext
Loop
End If
myrs1.MoveFirst
Dim i As Integer
i = 1
With MSF1
.Rows = z + 1
.Row = 0
If myrs1.EOF = False Then
myrs1.MoveFirst
Do While Not myrs1.EOF
.Row = .Row + 1
For i = 1 To myrs1.Fields.Count
.TextMatrix(.Row, i) = myrs1.Fields(i - 1)
Next i
myrs1.MoveNext
Loop
End If
End With
sql = "select * from "表名" where "字段名"= & combobox2
Set myrs1 = mydata.OpenRecordset(sql)
这时myrs1就是你想要数据的集合,再进行写入到msflexgrid
If myrs1.EOF = False Then
myrs1.MoveFirst
Do While Not myrs1.EOF
z = z + 1
myrs1.MoveNext
Loop
End If
myrs1.MoveFirst
Dim i As Integer
i = 1
With MSF1
.Rows = z + 1
.Row = 0
If myrs1.EOF = False Then
myrs1.MoveFirst
Do While Not myrs1.EOF
.Row = .Row + 1
For i = 1 To myrs1.Fields.Count
.TextMatrix(.Row, i) = myrs1.Fields(i - 1)
Next i
myrs1.MoveNext
Loop
End If
End With
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询