是否可以使用特定数量的CheckedListBox设置过滤? [英] Is it possible to set filtering using a specific number of CheckedListBox?
本文介绍了是否可以使用特定数量的CheckedListBox设置过滤?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因为我有6个CheckedListBox,每当我从4个CheckedListBox中选择项目时,会弹出一个错误,但它仍会过滤。
*更新
(对于每个CheckedBoxList,这是我使用但具有不同变量名的代码)
还有一种方法可以将多个数据合并为一个吗?例如,当我在Client 4x中输入John时,它会在CheckedListBox中显示John(x4)。但目标是过滤..有没有办法让约翰出现一次?
Because I have 6 CheckedListBox and whenever I select items from 4 CheckedListBoxes only, an error pops up but it still filters.
*UPDATED
(For every CheckedBoxList, this is the code that I use but with different variable names)
And also is there a way to make multiple data into one? Example is, when I input John in Client 4x, it would show John(x4) in the CheckedListBox. But the goal is to filter.. Is there a way to make John appear once?
Dim dt1 As DataTable
Dim ds1 As New DataSet
cnn = New OleDbConnection(connectionString)
Dim clientList As String = "("
For item1 As Integer = 0 To CheckedListBox2.CheckedItems.Count - 1
clientList += "'" & CheckedListBox2.CheckedItems(item1) & "',"
Next
clientList = clientList.Substring(0, clientList.Length - 1) + ")"
Dim sql1 = "select * from NTIdb where Client in " + clientList
Try
cnn.Open()
adptr = New OleDbDataAdapter(sql1, cnn)
adptr.Fill(ds1)
adptr.Dispose()
cnn.Close()
dt1 = ds1.Tables(0)
Form5.DataGridView1.DataSource = dt1
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Form5.DataGridView1.Visible = True
推荐答案
也许你可以使用在您的SQL语句中是不同的。例如:
Dim sql1 =从NTIdb中选择distinct< requiredcolumnonly>其中客户端位于+ clientList
Maybe you can use distinct in your SQL statement. For example:
Dim sql1 = "select distinct <requiredcolumnonly> from NTIdb where Client in " + clientList
这篇关于是否可以使用特定数量的CheckedListBox设置过滤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文