首页上一页 1 下一页尾页 1 条记录 1/1页
vb书配的光盘上的数据处理例子实现出现问题,急!
发表在VB答疑区
2016-03-16
是否精华
是
否
版块置顶:
是
否
在光盘的实例资源库——vb综合范例库——数据处理技术——在DataGrid表格中实现下拉列表框,出现位置错乱的问题,拜托老师看下什么原因,急!谢谢!
代码如下:
Private Sub Form_Load()
Call SJK(db) '调用数据库连接
strSQL = "select * from 课程表 where 上课老师='" & Frm_login.Text1.Text & "'" '数据表连接字符串
RS.Open strSQL, db, 2, 2 '打开数据表
Text1.Text = Frm_login.Text1.Text
DataGrid1.Columns(3).Button = True
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\A.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "12电信考勤表"
Set DataGrid1.DataSource = Adodc1
List1.AddItem ("正常")
List1.AddItem ("迟到")
List1.AddItem ("早退")
List1.AddItem ("请假")
List1.AddItem ("缺旷")
DataGrid1.Columns(3).Button = True
End Sub
Private Sub DataGrid1_ButtonClick(ByVal ColIndex As Integer)
If Not List1.Visible Then
List1.Visible = True
List1.Width = DataGrid1.Columns(3).Width
List1.Left = DataGrid1.Left + DataGrid1.Columns(3).Left
List1.Top = DataGrid1.RowTop(DataGrid1.Row) + DataGrid1.RowHeight
End If
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
List1.Visible = False
End Sub
Private Sub List1_Click()
DataGrid1.Columns(3).Text = List1.Text
List1.Visible = False
End Sub
代码如下:
Private Sub Form_Load()
Call SJK(db) '调用数据库连接
strSQL = "select * from 课程表 where 上课老师='" & Frm_login.Text1.Text & "'" '数据表连接字符串
RS.Open strSQL, db, 2, 2 '打开数据表
Text1.Text = Frm_login.Text1.Text
DataGrid1.Columns(3).Button = True
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\A.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "12电信考勤表"
Set DataGrid1.DataSource = Adodc1
List1.AddItem ("正常")
List1.AddItem ("迟到")
List1.AddItem ("早退")
List1.AddItem ("请假")
List1.AddItem ("缺旷")
DataGrid1.Columns(3).Button = True
End Sub
Private Sub DataGrid1_ButtonClick(ByVal ColIndex As Integer)
If Not List1.Visible Then
List1.Visible = True
List1.Width = DataGrid1.Columns(3).Width
List1.Left = DataGrid1.Left + DataGrid1.Columns(3).Left
List1.Top = DataGrid1.RowTop(DataGrid1.Row) + DataGrid1.RowHeight
End If
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
List1.Visible = False
End Sub
Private Sub List1_Click()
DataGrid1.Columns(3).Text = List1.Text
List1.Visible = False
End Sub