如何在vb.NET的dataGridView中放置搜索功能
如何从datagridView中的选定行中选择一个单元格,并在选择后设置简单的搜索功能(就像我们在windows文件夹中键入任何字符,搜索应该可以正常工作)?我不太理解您的问题。如果要选择一个单元格,可以使用celldoubleclick事件作为示例。要获取所选单元格,请使用e.rowindex和e.columnindex,这将为您提供单元格所在的行和列。您可以尝试使用此解决方案如何在vb.NET的dataGridView中放置搜索功能,vb.net,winforms,vb6-migration,Vb.net,Winforms,Vb6 Migration,如何从datagridView中的选定行中选择一个单元格,并在选择后设置简单的搜索功能(就像我们在windows文件夹中键入任何字符,搜索应该可以正常工作)?我不太理解您的问题。如果要选择一个单元格,可以使用celldoubleclick事件作为示例。要获取所选单元格,请使用e.rowindex和e.columnindex,这将为您提供单元格所在的行和列。您可以尝试使用此解决方案 Dim nwData as CustomersDataSet = CustomersDataSet.GetCusto
Dim nwData as CustomersDataSet = CustomersDataSet.GetCustomers()
m_CustomersGrid.DataSource = m_CustomersBindingSource
m_CustomersBindingSource.DataSource = nwData.Customers
Then you can sort using the BindingSource.
CustomersBindingSource.Sort = "ContactName ASC"
And you can find using the BindingSource.
Dim index as integer = _
CustomersBindingSource.Find("CompanyName", CompanyNameTextBox.Text)
If index <-1 then 'it was found; move to that position
CustomersBindingSource.Position = index
End If
在单元格中按下按键时,通过使用以下方式捕捉按键:
Private Sub DataGridView1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyUp
Dim dgv As DataGridView = TryCast(sender, DataGridView)
If dgv IsNot Nothing Then
'You will need some logic here to determine how long to wait between keyups
'Perhaps a timer that ticks every500 milliseconds and reset on keyup.
e.KeyData
End If
End Sub
我在:找到了原始的竞价源逻辑,我想把简单的搜索功能放在我们的目录或文件夹中。比如,如果你输入'ab',所有以ab开头的文件都列在第一位,这与我想申请dataGridView的内容是一样的。
Private Sub DataGridView1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyUp
Dim dgv As DataGridView = TryCast(sender, DataGridView)
If dgv IsNot Nothing Then
'You will need some logic here to determine how long to wait between keyups
'Perhaps a timer that ticks every500 milliseconds and reset on keyup.
e.KeyData
End If
End Sub