怎么清空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
...全文
540 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
vs2015+数据库,需要建的数据表如下: 1. “考试成绩管理系统用户登录”功能 具体要求: (1) 按照图示排列相应的控件,控件名称自定义,其中,界面中的图片可以不加; (2) 当输入正确的用户名和密码时,登录到主系统,如图所示,并且用户名或密码输入不正确时系统有所提示;当单击【取消】按钮时,用户名和密码被清空; (3) 程序中用到的数据库名为SCOREINFO,数据表名为userinfo,数据表结构如下图所示: (4) 数据表中的用户名和密码如下图。 2. 点击主窗体的“密码修改”菜单,完成“密码修改”功能,程序运行如下图所示: 具体要求: (1)此题必须使用数据库连接完成,原始密码必须为数据表里原有的数据,不使用数据库完成的为0分。 (2)需要建立数据库SCOREINFO及数据表userinfo,表的结构及数据第一部分的内容: (3)要有“原始密码输入错误”、“原始密码不能为空”及“两次输入密码不一致”的错误提示; (4)当单击【保存】按钮,新密码被更新到数据表中,不能更新的为0分; (5)单击【关闭】按钮,窗口关闭。 (6)3个Label;3个TextBox;2个Button 3. 完成“成绩查询”功能,程序运行如下图所示: 具体要求: (1) 按照图示排列相应的控件,界面下方是DataGridView控件; (2)程序用到的数据库名为SCOREINFO,数据表名为score,表结构如下: (3)完成的MainForm_Load事件处理程序:当加载窗体时,直接在窗体的dataGridView1控件中显示数据表的所有记录; (4)可以设查询条件:首先在组合框comboBox1中选择查询条件,并在textBox1中输入条件值(可以模糊查询,如按照姓名查询时,输入“王”,可以查所有姓王的同学的成绩),单击查询将结果显示在dataGridView1控件中。 (5)所需控件及属性:1个GroupBox,1个Label,Text为选择查询条件;1个ComboBox(Items:学号、姓名);1个TextBox;1个Button,Text为查询;1个DataGridView 4. 完成“课程信息修改”功能,程序运行如下图所示: 具体要求: (1)按照图示排列相应的控件,控件名称自定义,其中,程序刚开始运行时,“学分”和“课程编码”的文本框是只读的; (2)在数据库名为SCOREINFO中,创建数据表名为course,表结构如下: (3)当单击【查询】时,直接在窗体的dataGridView2控件中显示数据表的所有记录; (4)当选中DataGridView控件中的某一行记录时(DataGridView控件的Mouse_Click事件),“课程名字”、“学分”、“课程代码”文本框中分别显示该项对应的课程信息; (5)当选中某一行记录并单击【编辑】按钮时,【编辑】按钮变为【保存修改】,同时“学分”和“课程编码”的文本框恢复正常(ReadOnly属性为false);在文本框中修改相应的信息后单击【保存修改】,将修改后的数据更新到数据表中。 (6)所需控件及属性:1个GroupBox,3个Label;3个TextBox(textBox2属性ReadOnly为True,textBox3属性ReadOnly为True);2个Button;1个DataGridView 5. 完成“课程信息删除”功能,程序运行如下图所示: 具体要求: (1)按照图示排列相应的控件,控件名称自定义,其中,程序刚开始运行时,“学分”和“课程编码”的文本框是只读的; (2)数据表名为course,表结构同第4部分: (3)当单击【查询】时,直接在窗体的dataGridView控件中显示数据表的所有记录; (4)当选中DataGridView控件中的某一行记录时,“课程名字”、“学分”、“课程代码”文本框中分别显示该项对应的课程信息; (5)当选中某一行记录并单击【删除】按钮时,则该行从数据表中删除。 (6)所需控件:3个Label;3个TextBox(textBox2属性ReadOnly为True,textBox3属性ReadOnly为True);2个Button;1个DataGridView 6. 完成“课程信息添加”功能,程序运行如下图所示: 具体要求: (1)按照图示排列相应的控件,控件名称自定义; (2)程序用到的数据库和数据表名为course,表结构如下同第四部分: (3)当单击【查询】时,直接在窗体的dataGridView1控件中显示数据表的所有记 (4)当选中DataGridView控件中的某一行记录时,“课程名字”、“学分”、“课程代码”文本框中分别显示该项对应的课程信息; (5)当单击【添加】按钮时,在文本框中添加新的内容并将新内容添加到数据表中,并且在DataGridView控件中显示出新的课程信息 (6)所需控件:3个Label;3个TextBox;2个Button;1个DataGridView

7,765

社区成员

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

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