0
我有一個datagridview,我想過濾。vb.net DataGridView更新標籤,而打字
在datagridview上面,我有第二個單行空過濾器datagridview具有相同數量的列。
當用戶輸入其中一個單元格時,我想根據過濾器datagridview的填充單元格過濾主datagridview。
在應用過濾器之前,我想在當前單元格文本仍在編輯時更新標籤。
如何在編輯結束前獲取用戶更改的文本?
我有一個datagridview,我想過濾。vb.net DataGridView更新標籤,而打字
在datagridview上面,我有第二個單行空過濾器datagridview具有相同數量的列。
當用戶輸入其中一個單元格時,我想根據過濾器datagridview的填充單元格過濾主datagridview。
在應用過濾器之前,我想在當前單元格文本仍在編輯時更新標籤。
如何在編輯結束前獲取用戶更改的文本?
解決 - 與c.EditedFormattedValue.ToString
Private Sub dgvFilter_EditingControlShowing(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) _
Handles dgvFilter.EditingControlShowing
Dim tb As TextBox = TryCast(e.Control, TextBox)
If (tb IsNot Nothing) Then
RemoveHandler tb.KeyUp, AddressOf tb_KeyUp
AddHandler tb.KeyUp, AddressOf tb_KeyUp
'RemoveHandler tb.KeyDown, AddressOf tb_KeyDown
'AddHandler tb.KeyDown, AddressOf tb_KeyDown
End If
End Sub
Private Sub tb_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
Dim c As DataGridViewCell = dgvFilter.CurrentCell
Dim s As String = c.EditedFormattedValue.ToString
Dim totalFilter As String
lblKeyCode.Text = e.KeyCode
'If e.KeyCode <> Keys.Down Then
cellName = dgvFilter.Columns(dgvFilter.CurrentCell.ColumnIndex).Name
cellFilter = "[" & cellName & "] LIKE '" & s & "%'"
'get the filter (other columns plus current column)
totalFilter = FilterString(dgvFilter, cellFilter)
Me.txtFilter.Text = totalFilter
'apply the filter
Me.lookupDataTable.DefaultView.RowFilter = totalFilter
'Else
'dgv.Focus()
'End If
End Sub