S
S Baig
Guest
There is a DataGridView on the Form and once I click on a specific column of DataGridView1, a Checkedlistbox will pop up and based on the selection of items in checkedlistbox, it should write SQL query and get only that data (Strictly on selection) on DataGridView1. The code is as below:
Please know I cannot use the button.
Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck
Dim i As Integer
'xx is an array of string, used to store checkedlistbox selection
Dim xx() As String
Dim sqlstr2 As String
For i = 0 To CheckedListBox1.Items.Count - 1 Step i + 1
If CheckedListBox1.GetItemCheckState(i) = CheckState.Checked Then
xx(i) = CheckedListBox1.SelectedValue(i)
End If
Next
sqlstr2 = "SELECT * From Table WHERE [TagName] in (' "%, "' '"& [xx] & "' )"'
SQL.RunQuery(sqlstr2)
If SQL.SQLDataset.Tables.Count > 0 Then
DataGridView1.DataSource = SQL.SQLDataset.Tables(0)
End If
End Sub
Continue reading...
Please know I cannot use the button.
Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck
Dim i As Integer
'xx is an array of string, used to store checkedlistbox selection
Dim xx() As String
Dim sqlstr2 As String
For i = 0 To CheckedListBox1.Items.Count - 1 Step i + 1
If CheckedListBox1.GetItemCheckState(i) = CheckState.Checked Then
xx(i) = CheckedListBox1.SelectedValue(i)
End If
Next
sqlstr2 = "SELECT * From Table WHERE [TagName] in (' "%, "' '"& [xx] & "' )"'
SQL.RunQuery(sqlstr2)
If SQL.SQLDataset.Tables.Count > 0 Then
DataGridView1.DataSource = SQL.SQLDataset.Tables(0)
End If
End Sub
Continue reading...