【发布时间】:2014-02-18 01:29:07
【问题描述】:
我一直在为我的 datagridview 修复 textChanged like 事件,但我无法获得我想要的结果。每当我更改其单元格上的文本时,dataGridView1 必须过滤 dataGridView2 的内容。
这可以过滤我的 dataGridView2 的内容,但在此之前我必须单击 dataGridView1 外部的光标/按 Tab。这是我的代码:
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
Dim con1 As OleDbConnection = con
con1.Open()
Dim dt As New DataTable
Dim _command As OleDbCommand = New OleDbCommand()
_command.Connection = con1
_command.CommandText = "SELECT * FROM table_name WHERE " & likeContent & ""
dt.Load(_command.ExecuteReader)
Me.dgv.DataSource = dt
con1.Close()
End Sub
“likecontent”是我在 dataGridView1 上存储文本的位置。
我的 dataGridView2 将如何仅由我的 dataGridView1 中的 textChanged 类事件更新?
【问题讨论】:
-
检查 this MSDN post 关于 CellValueChanged 事件,这将解释为什么你还需要收听 CurrentCellDirtyStateChanged
标签: vb.net datagridview textchanged