嘿我这里有一段代码有问题我有一个树视图框,它也链接到邮政编码搜索和一个确定名称搜索..好吧,他们更多的是过滤器。但是我已经链接了Treeview,所以一旦点击它就会填充Fields,但它只适用于第一个选项卡,我想知道我怎么会这样做呢?
这是loadMemberTree的代码
Sub LoadMemberTree()
'**Loads Client List
' Error Checking
On Error GoTo Err_LoadMemberTree
' Dimension Local Variables
Dim uRecSnap As ADODB.Recordset
Dim uPar As ADODB.Parameter
Dim uNode As TreeNode
Dim iCategoryID As Integer = 0
Dim iCategoryCnt As Integer = 0
Dim iMemberID As Integer = 0
Dim iMemberCnt As Integer = 0
' Check For Open Connection
If uDBase Is Nothing Then
OpenConnection()
bConnection = True
End If
' Run Stored Procedure - Load Client List (Based on Search Value)
uCommand = New ADODB.Command
With uCommand
.ActiveConnection = uDBase
.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
.CommandTimeout = 0
uPar = .CreateParameter("@Surname", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
.Parameters.Append(uPar)
.Parameters("@Surname").Value = txtSearchSurname.Text
uPar = .CreateParameter("@Postcode", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 80)
.Parameters.Append(uPar)
.Parameters("@Postcode").Value = txtSearchPostcode.Text
.CommandText = "Member_LoadRecordsByCategory"
uRecSnap = .Execute
End With
' Suppress TreeView Repaint / Clear TreeView
tvwMember.BeginUpdate()
tvwMember.Nodes.Clear()
tvwMember.ShowNodeToolTips = True
' Populate List
Do Until uRecSnap.EOF
If iMemberID <> uRecSnap("CategoryID").Value Then
uNode = tvwMember.Nodes.Add(Format(uRecSnap("CategoryID").Value, "00"), uRecSnap("CategoryDescription").Value)
uNode.Tag = "C:" & Format(uRecSnap("CategoryID").Value, "00") & ":0000:"
iCategoryID = uRecSnap("CategoryID").Value
iCategoryCnt = iCategoryCnt + 1
iMemberID = 0
iMemberCnt = 0
End If
If (IsDBNull(uRecSnap("MemberID").Value)) = False Then
If iMemberID <> uRecSnap("MemberID").Value Then
uNode = tvwMember.Nodes(iCategoryCnt - 1).Nodes.Add(Format(uRecSnap("MemberID").Value, "0000"), uRecSnap("FullName").Value)
uNode.Tag = "M:" & Format(uRecSnap("CategoryID").Value, "00") & ":" & Format(uRecSnap("MemberID").Value, "0000") & ":"
iMemberID = uRecSnap("MemberID").Value
iMemberCnt = iMemberCnt + 1
End If
End If
uRecSnap.MoveNext()
Loop
uRecSnap.Close()
' Repaint TreeView.
tvwMember.EndUpdate()
tvwMember.Refresh()
' Close Connection
If bConnection Then CloseConnection()
uRecSnap = Nothing
Err_LoadMemberTree:
If Err.Number <> 0 Then
sErrDescription = Err.Description
WriteAuditLogRecord(Me.Name, "LoadClientTree", "Error", sErrDescription)
MsgBox("System Error occurred" & Chr(13) & "LoadClientTree" & Chr(13) & sErrDescription, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "ICOM - Error Reporting")
End If
这是在设计视图中单击树视图框时运行的代码
Private Sub tvwMember_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles tvwMember.AfterSelect
' Dimension Local Variables
Dim iMemberID As Integer
iMemberID = Val(tvwMember.SelectedNode.Tag.ToString.Substring(5, 4))
tabMember.Enabled = (iMemberID <> 0)
If iMemberID = 0 Then
' Clear Details Data
lblMemberIDValue.Text = "0000"
txtMembershipNo.Text = ""
cmbCategory.SelectedIndex = 0
dtpDateJoined.Value = Now
txtTitle.Text = ""
txtForename.Text = ""
txtSurname.Text = ""
txtAddition.Text = ""
txtJobTitle.Text = ""
txtDepartment.Text = ""
txtInstitution.Text = ""
txtAddress1.Text = ""
txtAddress2.Text = ""
txtAddress3.Text = ""
txtTown.Text = ""
txtPostcode.Text = ""
txtPhoneNo.Text = ""
txtMobileNo.Text = ""
txtEMailAddress.Text = ""
txtWebsite.Text = ""
' Clear Mailing Address Data
txtMAddress1.Text = ""
txtMAddress2.Text = ""
txtMAddress3.Text = ""
txtMTown.Text = ""
txtMPostcode.Text = ""
txtMPhoneNo.Text = ""
txtMMobileNo.Text = ""
txtMEMailAddress.Text = ""
cmbCommittee1.SelectedIndex = 0
cmbCommittee2.SelectedIndex = 0
cmbCommittee3.SelectedIndex = 0
cmbCommittee4.SelectedIndex = 0
cmbCommittee5.SelectedIndex = 0
txtRepresentativeName1.Text = ""
txtRepresentativeName2.Text = ""
txtRepresentativeName3.Text = ""
txtRepresentativeName4.Text = ""
txtRepresentativeName5.Text = ""
Else
tvwMember.Tag = iMemberID
' txtSearchMemberID.Text = tvwMember.SelectedNode.Text
With objMember
.MemberID = iMemberID
.LoadMember()
lblMemberIDValue.Text = Format(iMemberID, "0000")
txtMembershipNo.Text = .MemberShipNo
For iRCnt = 0 To cmbCategory.Items.Count - 1
If cmbCategory.Items.Item(iRCnt).ToString = .CategoryDescription Then
cmbCategory.SelectedIndex = iRCnt
End If
Next
dtpDateJoined.Value = .DateJoined
txtTitle.Text = .Title
txtForename.Text = .Forename
txtSurname.Text = .Surname
txtAddition.Text = .Addition
txtJobTitle.Text = .JobTitle
txtDepartment.Text = .Department
txtInstitution.Text = .Institution
txtAddress1.Text = .AddressLine1
txtAddress2.Text = .AddressLine2
txtAddress3.Text = .AddressLine3
txtTown.Text = .Town
txtPostcode.Text = .Postcode
txtPhoneNo.Text = .PhoneNo
txtMobileNo.Text = .MobileNo
txtEMailAddress.Text = .EMailAddress
txtWebsite.Text = .WebSite
txtMAddress1.Text = .MAddressLine1
txtMAddress2.Text = .MAddressLine2
txtMAddress3.Text = .MAddressLine3
txtMTown.Text = .MTown
txtMPostcode.Text = .MPostCode
txtMEMailAddress.Text = .MEmailAddress
txtMPhoneNo.Text = .MPhoneNo
txtMMobileNo.Text = .MMobileNo
' Clear Mailing Address Data
txtMAddress1.Text = ""
txtMAddress2.Text = ""
txtMAddress3.Text = ""
txtMTown.Text = ""
txtMPostcode.Text = ""
txtMPhoneNo.Text = ""
txtMMobileNo.Text = ""
txtMEMailAddress.Text = ""
cmbCommittee1.SelectedIndex = 0
cmbCommittee2.SelectedIndex = 0
cmbCommittee3.SelectedIndex = 0
cmbCommittee4.SelectedIndex = 0
cmbCommittee5.SelectedIndex = 0
txtRepresentativeName1.Text = ""
txtRepresentativeName2.Text = ""
txtRepresentativeName3.Text = ""
txtRepresentativeName4.Text = ""
txtRepresentativeName5.Text = ""
End With
End If
tsbNewMember.Enabled = False
tsbSaveMember.Enabled = True
tsbRemoveMember.Enabled = False
tabMember.SelectedIndex = 0
tabMember.SelectedIndex = 0
tsbSaveMember.Enabled = True
End Sub