1、你的DataColChanged时间的代码:
cm.CommandText = "SELECT 考核内容,序号,岗位 From {绩效考核项}"
可是你的后台并没有名称为“绩效考核项”的表,只有“考核项目”表,不要表Foxtable中的名称和后台的名称混淆了。
而且为什么要从后台提取数据,直接从已经加载的绩效考核项提取就行:
Dim dt As DataTable = DataTables("绩效考核项")
Select Case e.DataCol.Name
Case = "责任人"
Dim dr As DataRow = dt.Find("姓名 = " & "'" & e.DataRow("责任人") & "'" )
If dr IsNot Nothing '如果找到, 则设置各列内容
e.DataRow("部门") = dr("部门")
e.DataRow("岗位") = dr("岗位")
End If
Case "考核内容"
Dim dr As DataRow = dt.Find("考核内容 = " & "'" & e.DataRow("考核内容") & "' and 岗位 = " & "'" & e.DataRow("岗位") & "'" )
If dr IsNot Nothing '如果找到, 则设置各列内容
e.DataRow("考核序号") = dr("序号")
End If
End Select
2、PrePareEdit时间中不应该有计算量大的代码,你现在这样的代码,一定是卡的,PrepareEdit事件的代码应该改为:
If e.IsFocusCell Then
Select Case e.col.name
Case "考核内容"
Tables("现场检查").cols("考核内容").ComboList = DataTables("绩效考核项").GetComboListString("考核内容", "岗位 = '" & e.Row("岗位") & "'")
Case "考核序号"
If e.Row("考核内容") IsNot Nothing Then
Tables("现场检查").cols("考核序号").ComboList = DataTables("绩效考核项").GetComboListString("序号", "岗位 = '" & e.Row("岗位") & "' and 考核内容 = '" & e.Row("考核内容") & "'")
Else
Tables("现场检查").cols("考核序号").ComboList = DataTables("绩效考核项").GetComboListString("序号", "岗位 = '" & e.Row("岗位") & "'")
End If
End Select
End If
您学了很多知识,但是消化不好,你用的都是高级却不高效的方法,建议先不要着急开发,先再系统温习一下帮助。
例如这种动态列表项目,帮助都有介绍的: