怎么清空datagridview 2

dadihongchang 2011-07-05 09:49:36
Private Sub vsgCustomer_Click()
Dim pblnMatch As Boolean
Dim pintRow As Integer
If vsgCustomer.Visible = False Or vsgCustomer.Row < vsgCustomer.FixedRows Then
Exit Sub
End If

If vsgCustomer.Rows <= vsgCustomer.FixedRows Then
vsgCustomer.Visible = False
Exit Sub
End If
If vsgCustomer.TextMatrix(vsgCustomer.Row, 7) = "vcrTeleNum" Then
Exit Sub
End If



' For Brand Name
' ----------------------------
If pstrCustomerValueFrom = "Brand Name" Then

If Trim(vsgCustomer.TextMatrix(vsgCustomer.Row, 4)) <> "" Then
If vsgCustomer.Row > 0 Then
MsgBox "This Customer has been suspended in CCDS." & Chr(13) & Chr(13) & _
"Suspended On : " & Format(vsgCustomer.TextMatrix(vsgCustomer.Row, 4)) & Chr(13) & _
"Suspended By : " & IIf(Trim(vsgCustomer.TextMatrix(vsgCustomer.Row, 6)) = "", "---", "Staff ID (" & Trim(vsgCustomer.TextMatrix(vsgCustomer.Row, 6)) & ")") & Chr(13) & _
"Suspend Reason : " & IIf(Trim(vsgCustomer.TextMatrix(vsgCustomer.Row, 5)) = "", "---", Trim(vsgCustomer.TextMatrix(vsgCustomer.Row, 5))), 64, "Information"
Exit Sub
End If
End If

Me.txtBrandNameID = vsgCustomer.TextMatrix(vsgCustomer.Row, 1)
Me.txtBrandName = vsgCustomer.TextMatrix(vsgCustomer.Row, 2)
Me.txtBrandDebtorCode = vsgCustomer.TextMatrix(vsgCustomer.Row, 10)

tabApplication.Tab = 0
txtReptDelivery.SetFocus
End If
' ----------------------------

vsgCustomer.Visible = False

pstrCustomerValueFrom = ""
End Sub

Private Sub vsgCustomer_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call vsgCustomer_Click
End If
End Sub

Private Sub vsgCustomer_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
vsgCustomer.Visible = False
End If
End Sub


Private Sub txtApplicantName_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 40 And vsgCustomer.Visible = True Then
vsgCustomer.SetFocus
SendKeys "{DOWN}"
Exit Sub
End If

End Sub

Private Sub txtApplicantName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Trim(txtApplicantName.Text) <> "" And Len(Trim(txtApplicantName.Text)) > gintMinLengthForSelectCustomer Then
If vsgCustomer.Visible = True Then
vsgCustomer_Click
Else
Me.txtApplicantContactPerson.SetFocus
End If
End If
If KeyAscii = 13 And Trim(txtApplicantName.Text) = "" Then
Me.txtApplicantContactPerson.SetFocus
End If
End Sub

Private Sub txtApplicantName_KeyUp(KeyCode As Integer, Shift As Integer)
If pstrCustomerValueFrom <> "Applicant" Then
vsgCustomer.Clear
vsgCustomer.Rows = vsgCustomer.FixedRows
pstrCustomerValueFrom = "Applicant"
End If
vsgContactPerson.Visible = False
'If Trim(txtApplicantName.Text) <> "" And _
Len(txtApplicantName.Text) > gintMinLengthForSelectCustomer And _
Not (KeyCode >= 37 And KeyCode <= 40) Then

If Trim(txtApplicantName.Text) <> "" And _
Len(txtApplicantName.Text) > gintMinLengthForSelectCustomer Then

If Len(txtApplicantName.Text) = gintMinLengthForSelectCustomer + 1 Or vsgCustomer.Rows <= vsgCustomer.FixedRows Then
vsgCustomer.Visible = True
vsgCustomer.Rows = 1

vsgCustomer.Left = 240
vsgCustomer.Top = 1035
vsgCustomer.Height = 6595
vsgCustomer.Width = 14175
vsgCustomer.TabIndex = txtApplicantName.TabIndex + 1

SelectRecordForGrid rsSelectRec, " SELECT intCustID, vcrFullName, vcrEAddress, datSuspendedDate, nvcSuspendReason, " & _
" vcrSuspendBy, vcrTeleNum, vcrFaxNum, vcrEmail,vcrDebtorCode, chrDepartment, " & _
" datBlacklist, nvcBlackListReason, vcrBlackListBy " & _
" FROM STRCentral.dbo.A_Inf_CompanyInfo " & _
" where vcrFullName like '" & RCo(txtApplicantName.Text) & "%' " & _
" Order by vcrFullName "

Set vsgCustomer.DataSource = rsSelectRec
With vsgCustomer

' For pintLoop = 1 To .Rows - 1
' .RowHeight(pintLoop) = 600
' Next
.RowHeightMin = 400
.ColWidth(0) = 0

.ColWidth(1) = 850
.TextMatrix(0, 1) = "ID"
.ColAlignment(1) = flexAlignLeftCenter

.ColWidth(2) = 4300
.TextMatrix(0, 2) = "Customer Name"
.ColAlignment(2) = flexAlignLeftCenter

.ColWidth(3) = 6600
.TextMatrix(0, 3) = "Address"
.ColAlignment(3) = flexAlignLeftCenter

.ColWidth(4) = 1050
.TextMatrix(0, 4) = "Susp. On"
.ColAlignment(4) = flexAlignLeftCenter

.ColWidth(5) = 0
.ColWidth(6) = 0
.ColWidth(7) = 0
.ColWidth(8) = 0
.ColWidth(9) = 0
.ColWidth(10) = 1150
.TextMatrix(0, 10) = "Debtor Code"
.ColAlignment(10) = flexAlignLeftCenter
.ColWidth(11) = 0
.ColWidth(12) = 0
.ColWidth(13) = 0
.ColWidth(14) = 0
.AutoSize .FixedCols, .Cols - 1
End With
Set rsSelectRec = Nothing
txtApplicantName.SetFocus

If KeyCode = 13 Then
vsgCustomer_Click
End If
Else
If Len(txtApplicantName.Text) > gintMinLengthForSelectCustomer + 1 Then
With vsgCustomer
For pintloop = 1 To .Rows - 1
If UCase(Left(.TextMatrix(pintloop, 2), Len(Trim(txtApplicantName.Text)))) = UCase(Trim(txtApplicantName.Text)) Then
For pintLoop1 = pintloop To .Rows - 1
' .RowHeight(pintLoop1) = 600
.RowHidden(pintLoop1) = False
Next
.Row = pintloop
Exit For
Else
.RowHidden(pintloop) = True
End If
Next
End With
If KeyCode = 13 Then
vsgCustomer_Click
End If
End If
End If
End If
End Sub
...全文
543 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

7,774

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧