Solved

load form not first event

Posted on 2016-08-19
3
27 Views
Last Modified: 2016-08-19
I have a form and in the on load I set an option box to .checked which a datagrid needs to choose the correct stored procedure, however, it appears that other events are happening first which means the code that grabs the data fails.

the attachment would be the screen control to adjust the category and the columns shown.
with separate events on startup neither can be set to checked as the first .checked calls the event which calls the datafill code

how can i ensure the options are checked to a default value first?

the culprit i think is the change events on these
   OPBulkRemainView1.Checked = True
        OpAllRemain.Checked = True

at present are separate events so both cannot be checked at form load

Imports System
Imports System.Text.RegularExpressions
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration

Public Class Form1
    Dim AllListBox As New List(Of ListBox)()
    Private dtWords As DataTable
    Private dtMatrix As DataTable

    Private Sub OnKeyUpTvi(sender As Object, e As KeyEventArgs) Handles TextSearchTvi.KeyUp, ListTvi.KeyUp
        Dim index = -1
        If TypeOf sender Is TextBox Then
            Dim tb = DirectCast(sender, TextBox)
            If tb.Equals(TextSearchTvi) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = ListTvi.FindString(tb.Text)
                    If index <> -1 Then
                        ListTvi.SetSelected(index, True)
                    End If
                    tb.Clear()
                    e.Handled = True
                End If
            End If
        ElseIf TypeOf sender Is ListBox Then
            Dim lb = DirectCast(sender, ListBox)
            If lb.Equals(ListTvi) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = lb.FindString(TextSearchTvi.Text)
                    If index <> -1 Then
                        lb.SetSelected(index, True)
                    End If
                    TextSearchTvi.Clear()
                    e.Handled = True
                ElseIf e.KeyCode.Equals(Keys.Back) Then
                    If TextSearchTvi.Text.Length > 0 Then
                        TextSearchTvi.Text = TextSearchAbi.Text.Substring(0, TextSearchTvi.Text.Length - 1)
                    End If
                Else
                    TextSearchTvi.Text = TextSearchTvi.Text + Convert.ToChar(e.KeyCode)
                End If
            End If
        End If
    End Sub
    Private Sub OnKeyUpGlass(sender As Object, e As KeyEventArgs) Handles TextSearchGlass.KeyUp, ListGlass.KeyUp
        Dim index = -1
        If TypeOf sender Is TextBox Then
            Dim tb = DirectCast(sender, TextBox)
            If tb.Equals(TextSearchGlass) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = ListGlass.FindString(tb.Text)
                    If index <> -1 Then
                        ListGlass.SetSelected(index, True)
                    End If
                    tb.Clear()
                    e.Handled = True
                End If
            End If
        ElseIf TypeOf sender Is ListBox Then
            Dim lb = DirectCast(sender, ListBox)
            If lb.Equals(ListGlass) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = lb.FindString(TextSearchGlass.Text)
                    If index <> -1 Then
                        lb.SetSelected(index, True)
                    End If
                    TextSearchGlass.Clear()
                    e.Handled = True
                ElseIf e.KeyCode.Equals(Keys.Back) Then
                    If TextSearchGlass.Text.Length > 0 Then
                        TextSearchGlass.Text = TextSearchAbi.Text.Substring(0, TextSearchGlass.Text.Length - 1)
                    End If
                Else
                    TextSearchGlass.Text = TextSearchGlass.Text + Convert.ToChar(e.KeyCode)
                End If
            End If
        End If
    End Sub
    Private Sub OnKeyUpCap(sender As Object, e As KeyEventArgs) Handles TextSearchCap.KeyUp, ListCap.KeyUp
        Dim index = -1
        If TypeOf sender Is TextBox Then
            Dim tb = DirectCast(sender, TextBox)
            If tb.Equals(TextSearchCap) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = ListCap.FindString(tb.Text)
                    If index <> -1 Then
                        ListCap.SetSelected(index, True)
                    End If
                    tb.Clear()
                    e.Handled = True
                End If
            End If
        ElseIf TypeOf sender Is ListBox Then
            Dim lb = DirectCast(sender, ListBox)
            If lb.Equals(ListCap) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = lb.FindString(TextSearchCap.Text)
                    If index <> -1 Then
                        lb.SetSelected(index, True)
                    End If
                    TextSearchCap.Clear()
                    e.Handled = True
                ElseIf e.KeyCode.Equals(Keys.Back) Then
                    If TextSearchCap.Text.Length > 0 Then
                        TextSearchCap.Text = TextSearchAbi.Text.Substring(0, TextSearchCap.Text.Length - 1)
                    End If
                Else
                    TextSearchCap.Text = TextSearchCap.Text + Convert.ToChar(e.KeyCode)
                End If
            End If
        End If
    End Sub
    Private Sub OnKeyUpAbi(sender As Object, e As KeyEventArgs) Handles TextSearchAbi.KeyUp, ListAbi.KeyUp
        Dim index = -1
        If TypeOf sender Is TextBox Then
            Dim tb = DirectCast(sender, TextBox)
            If tb.Equals(TextSearchAbi) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = ListAbi.FindString(tb.Text)
                    If index <> -1 Then
                        ListAbi.SetSelected(index, True)
                    End If
                    tb.Clear()
                    e.Handled = True
                End If
            End If
        ElseIf TypeOf sender Is ListBox Then
            Dim lb = DirectCast(sender, ListBox)
            If lb.Equals(ListAbi) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = lb.FindString(TextSearchAbi.Text)
                    If index <> -1 Then
                        lb.SetSelected(index, True)
                    End If
                    TextSearchAbi.Clear()
                    e.Handled = True
                ElseIf e.KeyCode.Equals(Keys.Back) Then
                    If TextSearchAbi.Text.Length > 0 Then
                        TextSearchAbi.Text = TextSearchAbi.Text.Substring(0, TextSearchAbi.Text.Length - 1)
                    End If
                Else
                    TextSearchAbi.Text = TextSearchAbi.Text + Convert.ToChar(e.KeyCode)
                End If
            End If
        End If
    End Sub
    Private Sub OnKeyUpCW(sender As Object, e As KeyEventArgs) Handles TextSearchCW.KeyUp, ListCW.KeyUp, ListAbi.KeyUp
        Dim index = -1
        If TypeOf sender Is TextBox Then
            Dim tb = DirectCast(sender, TextBox)
            If tb.Equals(TextSearchCW) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = ListCW.FindString(tb.Text)
                    If index <> -1 Then
                        ListCW.SetSelected(index, True)
                    End If
                    tb.Clear()
                    e.Handled = True
                End If
            End If
        ElseIf TypeOf sender Is ListBox Then
            Dim lb = DirectCast(sender, ListBox)
            If lb.Equals(ListCW) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = lb.FindString(TextSearchCW.Text)
                    If index <> -1 Then
                        lb.SetSelected(index, True)
                    End If
                    TextSearchCW.Clear()
                    e.Handled = True
                ElseIf e.KeyCode.Equals(Keys.Back) Then
                    If TextSearchCW.Text.Length > 0 Then
                        TextSearchCW.Text = TextSearchCW.Text.Substring(0, TextSearchCW.Text.Length - 1)
                    End If
                Else
                    TextSearchCW.Text = TextSearchCW.Text + Convert.ToChar(e.KeyCode)
                End If
            End If
        End If
    End Sub
    Private Sub OnKeyUpBulk(sender As Object, e As KeyEventArgs) Handles TxtBoxSearchBulk.KeyUp, ListBulk.KeyUp
        Dim index = -1
        If TypeOf sender Is TextBox Then
            Dim tb = DirectCast(sender, TextBox)
            If tb.Equals(TxtBoxSearchBulk) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = ListBulk.FindString(tb.Text)
                    If index <> -1 Then
                        ListBulk.SetSelected(index, True)
                    End If
                    tb.Clear()
                    e.Handled = True
                End If
            End If
        ElseIf TypeOf sender Is ListBox Then
            Dim lb = DirectCast(sender, ListBox)
            If lb.Equals(ListBulk) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = lb.FindString(TxtBoxSearchBulk.Text)
                    If index <> -1 Then
                        lb.SetSelected(index, True)
                    End If
                    TxtBoxSearchBulk.Clear()
                    e.Handled = True
                ElseIf e.KeyCode.Equals(Keys.Back) Then
                    If TxtBoxSearchBulk.Text.Length > 0 Then
                        TxtBoxSearchBulk.Text = TxtBoxSearchBulk.Text.Substring(0, TxtBoxSearchBulk.Text.Length - 1)
                    End If
                Else
                    TxtBoxSearchBulk.Text = TxtBoxSearchBulk.Text + Convert.ToChar(e.KeyCode)
                End If
            End If
        End If
    End Sub

    Public Sub FindAllListBox(ByVal ctrl As Control)

        For Each c As Control In ctrl.Controls
            If TypeOf c Is ListBox Then
                AllListBox.Add(c)
            Else
                If c.Controls.Count > 0 Then
                    FindAllListBox(c)
                End If
            End If
        Next

    End Sub
    Public Sub TagBulkWords()

        Dim StrVehCat
        Dim StrVehSupCat As String
        Dim connectionString As String = "Data Source=MAIN-PC\SQLEXPRESS;Initial Catalog=Dictionary;Integrated Security=True;MultipleActiveResultSets=True"
        Dim StrProcName As String
        StrProcName = ""
        StrVehCat = ""
        StrVehSupCat = ""
        If OpCarBulk.Checked = True Or OPBikeBulk.Checked = True Or OPLcvBulk.Checked = True Or OpOthersBulk.Checked = True Then
            If OpBulkTag.Checked = True Then
                StrProcName = "usp_InsertBulkTagWordsVehCat"
            Else
                StrProcName = "usp_DeleteBulkTagWordsVehCat"
            End If


            If OpCarBulk.Checked = True Then
                StrVehCat = "Car"
            End If
            If OPBikeBulk.Checked = True Then
                StrVehCat = "Motorcycle"
            End If
            If OPLcvBulk.Checked = True Then
                StrVehCat = "Lcv"
            End If
            If OpOthersBulk.Checked = True Then
                StrVehCat = "Others"
            End If

        End If

        If OpSupCarLcvOtherBulk.Checked = True Or OpSupBikeQuadBulk.Checked = True Then
            If OpBulkTag.Checked = True Then
                StrProcName = "usp_InsertBulkTagWordsSuper"
            Else
                StrProcName = "usp_DeleteBulkTagWordsSuper"
            End If


            If OpSupCarLcvOtherBulk.Checked = True Then
                StrVehSupCat = "CarLcvOthers"
            End If

            If OpSupBikeQuadBulk.Checked = True Then
                StrVehSupCat = "BikesQuads"
            End If

        End If

        If OpAllBulk.Checked = True Then
            If OpBulkTag.Checked = True Then
                StrProcName = "usp_InsertBulkTagWords"
            Else
                StrProcName = "usp_DeleteBulkTagWords"
            End If
        End If

        Using conTagBulk As New SqlConnection(connectionString)

                For Each Item In ListBulk.SelectedItems
                    If Not String.IsNullOrWhiteSpace(Item) Then
                        Using cmdTagBulk As New SqlCommand(StrProcName, conTagBulk)
                            cmdTagBulk.CommandType = CommandType.StoredProcedure
                            conTagBulk.Open()
                        cmdTagBulk.Parameters.AddWithValue("@Word", Item.ToString())
                        If OpCarBulk.Checked = True Or OPBikeBulk.Checked = True Or OPLcvBulk.Checked = True Or OpOthersBulk.Checked = True Then
                                cmdTagBulk.Parameters.AddWithValue("@VCategory", StrVehCat)
                            ElseIf OpSupCarLcvOtherBulk.Checked = True Or OpSupBikeQuadBulk.Checked = True Then
                                cmdTagBulk.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)
                            ElseIf OpAllBulk.Checked = True Then

                            End If
                            cmdTagBulk.ExecuteNonQuery()
                            conTagBulk.Close()
                        End Using
                    Else
                        'do nothing whitespace
                    End If
                Next
            End Using


            Call DataGroupCallBulk()

        If OpBulkTag.Checked = True Then
            MessageBox.Show("Finished Bulk Tagging.")
        Else
            MessageBox.Show("Finished Bulk Un-Tagging.")
        End If
    End Sub
    Public Sub TagWords()
        Dim StrVehCat As String

        Dim y As Long
        Dim StrVehSupCat As String
        Dim StrProcName As String
        Dim connectionString As String = "Data Source=MAIN-PC\SQLEXPRESS;Initial Catalog=Dictionary;Integrated Security=True;MultipleActiveResultSets=True"
        StrProcName = ""
        StrVehCat = ""
        StrVehSupCat = ""


        If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
            If OpTag.Checked = True Then
                StrProcName = "usp_InsertTagWordsVehCat"
            Else
                StrProcName = "usp_DeleteTagWordsVehCat"
            End If


            If OpCar.Checked = True Then
                StrVehCat = "Car"
            End If
            If OPBike.Checked = True Then
                StrVehCat = "Motorcycle"
            End If
            If OPLcv.Checked = True Then
                StrVehCat = "Lcv"
            End If
            If OpOthers.Checked = True Then
                StrVehCat = "Others"
            End If

        End If

        If OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
            If OpTag.Checked = True Then
                StrProcName = "usp_InsertTagWordsSuper"
            Else
                StrProcName = "usp_DeleteTagWordsSuper"
            End If


            If OpSupCarLcvOther.Checked = True Then
                StrVehSupCat = "CarLcvOthers"
            End If

            If OpSupBikeQuad.Checked = True Then
                StrVehSupCat = "BikesQuads"
            End If

        End If

        If OpAll.Checked = True Then
            If OpTag.Checked = True Then
                StrProcName = "usp_InsertTagWords"
            Else
                StrProcName = "usp_DeleteTagWords"
            End If
        End If


        If OpTag.Checked = True Then
            ProgressBar2.Step = 1
            ProgressBar2.Minimum = 1



            Using conTag As New SqlConnection(connectionString)
                For Each Item In ListCW.SelectedItems
                    y = ListCW.SelectedIndices.Count
                    ProgressBar2.Maximum = y
                    If Not String.IsNullOrWhiteSpace(Item) Then

                        Using cmdTag As New SqlCommand(StrProcName, conTag)
                            cmdTag.CommandType = CommandType.StoredProcedure
                            conTag.Open()
                            cmdTag.Parameters.AddWithValue("@Word", Item.ToString())
                            cmdTag.Parameters.AddWithValue("@Client", "Smmt")
                            If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCategory", StrVehCat)

                            ElseIf OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)

                            ElseIf OpAll.Checked = True Then

                            End If
                            cmdTag.ExecuteNonQuery()
                            conTag.Close()
                        End Using



                    Else
                        'do nothing whitespace
                    End If
                    ProgressBar2.PerformStep()
                Next

                For Each Item In ListAbi.SelectedItems
                    y = y + ListAbi.SelectedIndices.Count
                    ProgressBar2.Maximum = y
                    If Not String.IsNullOrWhiteSpace(Item) Then

                        Using cmdTag As New SqlCommand(StrProcName, conTag)
                            cmdTag.CommandType = CommandType.StoredProcedure
                            conTag.Open()
                            cmdTag.Parameters.AddWithValue("@Word", Item.ToString())
                            cmdTag.Parameters.AddWithValue("@Client", "Abi")
                            If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCategory", StrVehCat)

                            ElseIf OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)

                            ElseIf OpAll.Checked = True Then

                            End If
                            cmdTag.ExecuteNonQuery()
                            conTag.Close()
                        End Using
                    Else
                        'do nothing whitespace
                    End If
                    ProgressBar2.PerformStep()
                Next


                For Each Item In ListCap.SelectedItems
                    y = y + ListCap.SelectedIndices.Count
                    ProgressBar2.Maximum = y
                    If Not String.IsNullOrWhiteSpace(Item) Then

                        Using cmdTag As New SqlCommand(StrProcName, conTag)
                            cmdTag.CommandType = CommandType.StoredProcedure
                            conTag.Open()
                            cmdTag.Parameters.AddWithValue("@Word", Item.ToString())
                            cmdTag.Parameters.AddWithValue("@Client", "Cap")
                            If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCategory", StrVehCat)

                            ElseIf OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)

                            ElseIf OpAll.Checked = True Then

                            End If
                            cmdTag.ExecuteNonQuery()
                            conTag.Close()
                        End Using
                    Else
                        'do nothing whitespace
                    End If
                    ProgressBar2.PerformStep()
                Next

                For Each Item In ListGlass.SelectedItems
                    y = y + ListGlass.SelectedIndices.Count
                    ProgressBar2.Maximum = y
                    If Not String.IsNullOrWhiteSpace(Item) Then

                        Using cmdTag As New SqlCommand(StrProcName, conTag)
                            cmdTag.CommandType = CommandType.StoredProcedure
                            conTag.Open()
                            cmdTag.Parameters.AddWithValue("@Word", Item.ToString())
                            cmdTag.Parameters.AddWithValue("@Client", "Glass")
                            If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCategory", StrVehCat)

                            ElseIf OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)

                            ElseIf OpAll.Checked = True Then

                            End If
                            cmdTag.ExecuteNonQuery()
                            conTag.Close()
                        End Using
                    Else
                        'do nothing whitespace
                    End If
                    ProgressBar2.PerformStep()
                Next

                For Each Item In ListTvi.SelectedItems
                    y = y + ListTvi.SelectedIndices.Count
                    ProgressBar2.Maximum = y
                    If Not String.IsNullOrWhiteSpace(Item) Then

                        Using cmdTag As New SqlCommand(StrProcName, conTag)
                            cmdTag.CommandType = CommandType.StoredProcedure
                            conTag.Open()
                            cmdTag.Parameters.AddWithValue("@Word", Item.ToString())
                            cmdTag.Parameters.AddWithValue("@Client", "Tvi")
                            If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCategory", StrVehCat)

                            ElseIf OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)

                            ElseIf OpAll.Checked = True Then

                            End If
                            cmdTag.ExecuteNonQuery()
                            conTag.Close()
                        End Using
                    Else
                        'do nothing whitespace
                    End If
                    ProgressBar2.PerformStep()
                Next


            End Using
        Else
            'Un-Tag
            Using conTag As New SqlConnection(connectionString)
                For Each Item In ListCW.SelectedItems
                    y = ListCW.SelectedIndices.Count
                    ProgressBar2.Maximum = y
                    If Not String.IsNullOrWhiteSpace(Item) Then

                        Using cmdTag As New SqlCommand(StrProcName, conTag)
                            cmdTag.CommandType = CommandType.StoredProcedure
                            conTag.Open()
                            cmdTag.Parameters.AddWithValue("@Word", Item.ToString())
                            cmdTag.Parameters.AddWithValue("@Client", "Smmt")
                            If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCategory", StrVehCat)

                            ElseIf OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)

                            ElseIf OpAll.Checked = True Then

                            End If
                            cmdTag.ExecuteNonQuery()
                            conTag.Close()
                        End Using
                    Else
                        'do nothing whitespace
                    End If
                    ProgressBar2.PerformStep()
                Next

                For Each Item In ListAbi.SelectedItems
                    y = y + ListCap.SelectedIndices.Count
                    ProgressBar2.Maximum = y
                    If Not String.IsNullOrWhiteSpace(Item) Then

                        Using cmdTag As New SqlCommand(StrProcName, conTag)
                            cmdTag.CommandType = CommandType.StoredProcedure
                            conTag.Open()
                            cmdTag.Parameters.AddWithValue("@Word", Item.ToString())
                            cmdTag.Parameters.AddWithValue("@Client", "Abi")
                            If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCategory", StrVehCat)

                            ElseIf OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)

                            ElseIf OpAll.Checked = True Then

                            End If
                            cmdTag.ExecuteNonQuery()
                            conTag.Close()
                        End Using
                    Else
                        'do nothing whitespace
                    End If
                    ProgressBar2.PerformStep()
                Next


                For Each Item In ListCap.SelectedItems
                    y = y + ListCap.SelectedIndices.Count
                    ProgressBar2.Maximum = y
                    If Not String.IsNullOrWhiteSpace(Item) Then

                        Using cmdTag As New SqlCommand(StrProcName, conTag)
                            cmdTag.CommandType = CommandType.StoredProcedure
                            conTag.Open()
                            cmdTag.Parameters.AddWithValue("@Word", Item.ToString())
                            cmdTag.Parameters.AddWithValue("@Client", "Cap")
                            If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCategory", StrVehCat)

                            ElseIf OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)

                            ElseIf OpAll.Checked = True Then

                            End If
                            cmdTag.ExecuteNonQuery()
                            conTag.Close()
                        End Using
                    Else
                        'do nothing whitespace
                    End If
                    ProgressBar2.PerformStep()
                Next


                For Each Item In ListGlass.SelectedItems
                    y = y + ListGlass.SelectedIndices.Count
                    ProgressBar2.Maximum = y
                    If Not String.IsNullOrWhiteSpace(Item) Then

                        Using cmdTag As New SqlCommand(StrProcName, conTag)
                            cmdTag.CommandType = CommandType.StoredProcedure
                            conTag.Open()
                            cmdTag.Parameters.AddWithValue("@Word", Item.ToString())
                            cmdTag.Parameters.AddWithValue("@Client", "Glass")
                            If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCategory", StrVehCat)

                            ElseIf OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)

                            ElseIf OpAll.Checked = True Then

                            End If
                            cmdTag.ExecuteNonQuery()
                            conTag.Close()
                        End Using
                    Else
                        'do nothing whitespace
                    End If
                    ProgressBar2.PerformStep()
                Next
                For Each Item In ListTvi.SelectedItems
                    y = y + ListTvi.SelectedIndices.Count
                    ProgressBar2.Maximum = y
                    If Not String.IsNullOrWhiteSpace(Item) Then

                        Using cmdTag As New SqlCommand(StrProcName, conTag)
                            cmdTag.CommandType = CommandType.StoredProcedure
                            conTag.Open()
                            cmdTag.Parameters.AddWithValue("@Word", Item.ToString())
                            cmdTag.Parameters.AddWithValue("@Client", "Tvi")
                            If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCategory", StrVehCat)

                            ElseIf OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
                                cmdTag.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)

                            ElseIf OpAll.Checked = True Then

                            End If
                            cmdTag.ExecuteNonQuery()
                            conTag.Close()
                        End Using
                    Else
                        'do nothing whitespace
                    End If
                    ProgressBar2.PerformStep()
                Next
            End Using
        End If
        Call DataGroupCall()
        If OpTag.Checked = True Then
            MessageBox.Show("Finished Client Tagging.")
        Else
            MessageBox.Show("Finished Client Un-Tagging.")
        End If

    End Sub

    Public Function GetMatrixData(ByVal StrWordIn As String) As DataTable
        Dim StrProcName As String
        Dim StrWord As String
        StrWord = StrWordIn

        StrProcName = ""
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("Dictionary").ConnectionString
        dtMatrix = New DataTable

        If OpTag.Checked = True Then
            StrProcName = "usp_GetMatrix"
            Using connMatrix As New SqlConnection(connectionString)
                Using cmdMatrix As New SqlCommand(StrProcName, connMatrix)
                    cmdMatrix.CommandType = CommandType.StoredProcedure
                    connMatrix.Open()
                    cmdMatrix.Parameters.AddWithValue("@WordVar", StrWord)
                    Dim readerMatrix As SqlDataReader = cmdMatrix.ExecuteReader()

                    dtMatrix.Load(readerMatrix)

                End Using
            End Using
            Return dtMatrix
        Else
            Return dtMatrix
        End If
    End Function

    Public Function GetData(ByVal StrClient As String) As DataTable
        Dim StrProcName As String
        Dim StrVehCat As String
        StrProcName = ""
        StrVehCat = ""
        If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
            If OpTag.Checked = True Then
                StrProcName = "usp_GetWordsVehCat"
            Else
                StrProcName = "usp_GetTagWordsVehCat"
            End If
            If OpCar.Checked = True Then
                StrVehCat = "Car"
            End If
            If OPBike.Checked = True Then
                StrVehCat = "Motorcycle"
            End If
            If OPLcv.Checked = True Then
                StrVehCat = "Lcv"
            End If
            If OpOthers.Checked = True Then
                StrVehCat = "Others"
            End If

        End If

        If OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
            If OpTag.Checked = True Then
                StrProcName = "usp_GetWordsSuper"
            Else
                StrProcName = "usp_GetTagWordsSuper"
            End If
            If OpSupCarLcvOther.Checked = True Then
                StrVehCat = "CarLcvOthers"
            End If

            If OpSupBikeQuad.Checked = True Then
                StrVehCat = "BikesQuads"
            End If

        End If

        If OpAll.Checked = True Then
            If OpTag.Checked = True Then
                StrProcName = "usp_GetWords"
            Else
                StrProcName = "usp_GetTagWords"
            End If
        End If

        dtWords = New DataTable
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("Dictionary").ConnectionString

        Using conn As New SqlConnection(connectionString)
            Using cmd As New SqlCommand(StrProcName, conn)
                cmd.CommandType = CommandType.StoredProcedure
                conn.Open()

                cmd.Parameters.AddWithValue("@Client", StrClient)
                If OpCar.Checked = True Or OPBike.Checked = True Or OPLcv.Checked = True Or OpOthers.Checked = True Then
                    cmd.Parameters.AddWithValue("@VCategory", StrVehCat)

                ElseIf OpSupCarLcvOther.Checked = True Or OpSupBikeQuad.Checked = True Then
                    cmd.Parameters.AddWithValue("@VCatSuper", StrVehCat)

                ElseIf OpAll.Checked = True Then

                End If

                Dim reader As SqlDataReader = cmd.ExecuteReader()
                dtWords.Load(reader)
            End Using
        End Using
        Return dtWords
    End Function

    Public Function GetDataBulk() As DataTable
        Dim StrProcName As String
        Dim StrVehCat As String
        StrProcName = ""
        StrVehCat = ""

        If OpCarBulk.Checked = True Or OPBikeBulk.Checked = True Or OPLcvBulk.Checked = True Or OpOthersBulk.Checked = True Then
            If OpBulkTag.Checked = True Then
                StrProcName = "usp_GetBulkWordsVehCat"
            Else
                StrProcName = "usp_GetBulkTagWordsVehCat"
            End If
            If OpCarBulk.Checked = True Then
                StrVehCat = "Car"
            End If
            If OPBikeBulk.Checked = True Then
                StrVehCat = "Motorcycle"
            End If
            If OPLcvBulk.Checked = True Then
                StrVehCat = "Lcv"
            End If
            If OpOthersBulk.Checked = True Then
                StrVehCat = "Others"
            End If

        End If

        If OpSupCarLcvOtherBulk.Checked = True Or OpSupBikeQuadBulk.Checked = True Then
            If OpBulkTag.Checked = True Then
                StrProcName = "usp_GetBulkWordsSuper"
            Else
                StrProcName = "usp_GetBulkTagWordsSuper"
            End If
            If OpSupCarLcvOtherBulk.Checked = True Then
                StrVehCat = "CarLcvOthers"
            End If

            If OpSupBikeQuadBulk.Checked = True Then
                StrVehCat = "BikesQuads"
            End If

        End If

        If OpAllBulk.Checked = True Then
            If OpBulkTag.Checked = True Then
                StrProcName = "usp_GetBulkWords"
            Else
                StrProcName = "usp_GetBulkTagWords"
            End If
        End If

        dtWords = New DataTable
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("Dictionary").ConnectionString

        Using conn As New SqlConnection(connectionString)
            Using cmd As New SqlCommand(StrProcName, conn)
                cmd.CommandType = CommandType.StoredProcedure
                conn.Open()


                If OpCarBulk.Checked = True Or OPBikeBulk.Checked = True Or OPLcvBulk.Checked = True Or OpOthersBulk.Checked = True Then
                    cmd.Parameters.AddWithValue("@VCategory", StrVehCat)

                ElseIf OpSupCarLcvOtherBulk.Checked = True Or OpSupBikeQuadBulk.Checked = True Then
                    cmd.Parameters.AddWithValue("@VCatSuper", StrVehCat)

                ElseIf OpAll.Checked = True Then

                End If



                Dim reader As SqlDataReader = cmd.ExecuteReader()
                dtWords.Load(reader)
            End Using
        End Using
        Return dtWords
    End Function

    Public Function GetBulkDataStrings() As DataTable
        Dim StrProcName As String
        Dim StrVehCat As String
        StrProcName = ""
        StrVehCat = ""

        If OpShortDescCarsAll.Checked = True Or OpShortDescBikesAll.Checked = True Or OpShortDescLcvAll.Checked = True Or OpShortDescOthersAll.Checked = True Then

            If OpShortDescCarsAll.Checked = True Then
                StrVehCat = "Car"
            End If
            If OpShortDescBikesAll.Checked = True Then
                StrVehCat = "Motorcycle"
            End If
            If OpShortDescLcvAll.Checked = True Then
                StrVehCat = "Lcv"
            End If
            If OpShortDescOthersAll.Checked = True Then
                StrVehCat = "Others"
            End If

            StrProcName = "usp_GetBulkDescStringsVehCat"

        End If

        If OpShortDescCarsLcvOthersAll.Checked = True Or OpShortDescBikesQuadsAll.Checked = True Then
            StrProcName = "usp_GetBulkDescStringsSuper"
            If OpShortDescCarsLcvOthersAll.Checked = True Then
                StrVehCat = "CarLcvOthers"
            End If

            If OpShortDescBikesQuadsAll.Checked = True Then
                StrVehCat = "BikesQuads"
            End If

        End If

        If OpShortDescAllAll.Checked = True Then
            StrProcName = "usp_GetBulkDescStrings"
        End If

        dtWords = New DataTable
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("Dictionary").ConnectionString

        Using conn As New SqlConnection(connectionString)
            Using cmd As New SqlCommand(StrProcName, conn)
                cmd.CommandTimeout = 0
                cmd.CommandType = CommandType.StoredProcedure
                conn.Open()

                'cmd.Parameters.AddWithValue("@VCategory", StrVehCat)
                If OpShortDescCarsAll.Checked = True Or OpShortDescBikesAll.Checked = True Or OpShortDescLcvAll.Checked = True Or OpShortDescOthersAll.Checked = True Then
                    cmd.Parameters.AddWithValue("@VCategory", StrVehCat)

                ElseIf OpShortDescCarsLcvOthersAll.Checked = True Or OpShortDescBikesQuadsAll.Checked = True Then
                    cmd.Parameters.AddWithValue("@VCatSuper", StrVehCat)

                ElseIf OpShortDescAllAll.Checked = True Then

                End If

                Dim reader As SqlDataReader = cmd.ExecuteReader()
                dtWords.Load(reader)
            End Using
        End Using
        Return dtWords
    End Function


    Public Function GetBulkDataStringsRemain() As DataTable
        Dim StrProcName As String
        Dim StrVehCat As String
        StrProcName = ""
        StrVehCat = ""

        If OpCarRemain.Checked = True Or OpBikeRemain.Checked = True Or OpLCVRemain.Checked = True Or OpOtherRemain.Checked = True Then

            If OpCarRemain.Checked = True Then
                StrVehCat = "Car"
            End If
            If OpBikeRemain.Checked = True Then
                StrVehCat = "Motorcycle"
            End If
            If OpLCVRemain.Checked = True Then
                StrVehCat = "Lcv"
            End If
            If OpOtherRemain.Checked = True Then
                StrVehCat = "Others"
            End If

            If OPBulkRemainView1.Checked Then
                StrProcName = "usp_GetBulkRemainStringsVehCat"
            End If

            If OPBulkRemainView2.Checked Then
                StrProcName = "usp_GetBulkRemainStringsVehCatView2"
            End If

            If OPBulkRemainView3.Checked Then
                StrProcName = "usp_GetBulkRemainStringsVehCatView3"
            End If

        End If

        If OpCarLcvOtherRemain.Checked = True Or OpBikeQuadRemain.Checked = True Then

            If OPBulkRemainView1.Checked Then
                StrProcName = "usp_GetBulkRemainStringsSuper"
            End If

            If OPBulkRemainView2.Checked Then
                StrProcName = "usp_GetBulkRemainStringsSuperView2"
            End If

            If OPBulkRemainView3.Checked Then
                StrProcName = "usp_GetBulkRemainStringsSuperView3"
            End If



            If OpCarLcvOtherRemain.Checked = True Then
                StrVehCat = "CarLcvOthers"
            End If

            If OpBikeQuadRemain.Checked = True Then
                StrVehCat = "BikesQuads"
            End If

        End If

        If OpAllRemain.Checked = True Then

            If OPBulkRemainView1.Checked = True Then
                StrProcName = "usp_GetBulkRemainStrings"
            End If

            If OPBulkRemainView2.Checked = True Then
                StrProcName = "usp_GetBulkRemainStringsView2"
            End If

            If OPBulkRemainView3.Checked = True Then
                StrProcName = "usp_GetBulkRemainStringsView3"
            End If
        End If



        '*****************************************************************************************************************************

        dtWords = New DataTable
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("Dictionary").ConnectionString

        Using conn As New SqlConnection(connectionString)
            Using cmd As New SqlCommand(StrProcName, conn)
                cmd.CommandTimeout = 0
                cmd.CommandType = CommandType.StoredProcedure
                conn.Open()

                'cmd.Parameters.AddWithValue("@VCategory", StrVehCat)
                If OpCarRemain.Checked = True Or OpBikeRemain.Checked = True Or OpLCVRemain.Checked = True Or OpOtherRemain.Checked = True Then
                    cmd.Parameters.AddWithValue("@VCategory", StrVehCat)

                ElseIf OpCarLcvOtherRemain.Checked = True Or OpBikeQuadRemain.Checked = True Then
                    cmd.Parameters.AddWithValue("@VCatSuper", StrVehCat)

                ElseIf OpAllRemain.Checked = True Then

                End If

                Dim reader As SqlDataReader = cmd.ExecuteReader()
                dtWords.Load(reader)
            End Using
        End Using
        Return dtWords
    End Function

    Public Function GetDataStrings(ByVal StrClient As String) As DataTable

        Dim StrProcName As String
        Dim StrVehCat As String
        StrProcName = ""
        StrVehCat = ""

        If OpShortDescCars.Checked = True Or OpShortDescBikes.Checked = True Or OpShortDescLcv.Checked = True Or OpShortDescOthers.Checked = True Then

            If OpShortDescCars.Checked = True Then
                StrVehCat = "Car"
            End If
            If OpShortDescBikes.Checked = True Then
                StrVehCat = "Motorcycle"
            End If
            If OpShortDescLcv.Checked = True Then
                StrVehCat = "Lcv"
            End If
            If OpShortDescOthers.Checked = True Then
                StrVehCat = "Others"
            End If

            StrProcName = "usp_GetDescStringsVehCat"

        End If

        If OpShortDescCarsLcvOthers.Checked = True Or OpShortDescBikesQuads.Checked = True Then
            StrProcName = "usp_GetDescStringsSuper"
            If OpShortDescCarsLcvOthers.Checked = True Then
                StrVehCat = "CarLcvOthers"
            End If

            If OpShortDescBikesQuads.Checked = True Then
                StrVehCat = "BikesQuads"
            End If

        End If

        If OpShortDescAll.Checked = True Then
            StrProcName = "usp_GetDescStrings"
        End If

        dtWords = New DataTable
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("Dictionary").ConnectionString

        Using conn As New SqlConnection(connectionString)
            Using cmd As New SqlCommand(StrProcName, conn)
                cmd.CommandTimeout = 0
                cmd.CommandType = CommandType.StoredProcedure
                conn.Open()

                cmd.Parameters.AddWithValue("@Client", StrClient)

                If OpShortDescCars.Checked = True Or OpShortDescBikes.Checked = True Or OpShortDescLcv.Checked = True Or OpShortDescOthers.Checked = True Then
                    cmd.Parameters.AddWithValue("@VCategory", StrVehCat)

                ElseIf OpShortDescCarsLcvOthers.Checked = True Or OpShortDescBikesQuads.Checked = True Then
                    cmd.Parameters.AddWithValue("@VCatSuper", StrVehCat)

                ElseIf OpShortDescAll.Checked = True Then
                    ' no params
                End If

                Dim reader As SqlDataReader = cmd.ExecuteReader()
                dtWords.Load(reader)
            End Using
        End Using
        Return dtWords
    End Function
    Public Sub CreateAllStrs()
        LBLBulkWait.Visible = True
        Dim StrProcName As String
        StrProcName = "usp_CreateStrStringsPlusTidyup"

        Dim connectionString As String = ConfigurationManager.ConnectionStrings("Dictionary").ConnectionString

        Using conn As New SqlConnection(connectionString)
            Using cmd As New SqlCommand(StrProcName, conn)
                cmd.CommandTimeout = 0
                cmd.CommandType = CommandType.StoredProcedure
                conn.Open()
                cmd.ExecuteScalar()
            End Using
        End Using
        LBLBulkWait.Visible = False
    End Sub

    Private Sub PanelBTN_Click(sender As Object, e As EventArgs) Handles PanelBTN.Click
        Call CreateWords()
        Call UpdateVehicleCat()
    End Sub

    Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim ctrl As Control = TabControl1
        OPBulkRemainView1.Checked = True
        OPBulkDescView1.Checked = True
        OPDescView1.Checked = True

        LBLBulkWait.Visible = False
        OpAllBulk.Checked = True
        OpTag.Checked = True
        OpBulkTag.Checked = True
        OpAll.Checked = True
        OpShortDescAllAll.Checked = True
        OpShortDescAll.Checked = True
        OpAllRemain.Checked = True


        Call DataGroupCallBulk()
        Call DataGroupCall()
        Call DataGroupCallStringsBulk()
        Call DataGroupCallStrings()
        Call DataGroupCallRemain()
        'DataGridViewStringsCW.ClearSelection()
        'DataGridViewStringsAbi.ClearSelection()
        'DataGridViewStringsCap.ClearSelection()
        'DataGridViewStringsGlass.ClearSelection()
        'DataGridViewStringsTvi.ClearSelection()
        'DataGridViewStringsBulk.ClearSelection()
        'DataGridViewRemain.ClearSelection()
        'ListBulk.ClearSelected()
        'ListCW.ClearSelected()
        'ListAbi.ClearSelected()
        'ListCap.ClearSelected()
        'ListGlass.ClearSelected()
        'ListTvi.ClearSelected()

    End Sub

    Private Sub PanelBtnTag_Click(sender As Object, e As EventArgs) Handles PanelBtnTag.Click
        Call TagWords()
        'Call CreateAllStrs()
        'MessageBox.Show("Short Strings Created")
    End Sub

    Private Sub OpUnTag_Click(sender As Object, e As EventArgs) Handles OpUnTag.Click
        Call DataGroupCall()
    End Sub

    Private Sub OpTag_Click(sender As Object, e As EventArgs) Handles OpTag.Click
        Call DataGroupCall()
    End Sub

    Private Sub OpBulkTag_Click(sender As Object, e As EventArgs) Handles OpBulkTag.Click

        ListBulk.DataSource = GetDataBulk().AsEnumerable().Select(Function(r) r.Field(Of String)("Word")).ToList()

    End Sub
    Private Sub OpUnTagBulk_Click(sender As Object, e As EventArgs) Handles OpUnTagBulk.Click

        ListBulk.DataSource = GetDataBulk().AsEnumerable().Select(Function(r) r.Field(Of String)("Word")).ToList()

    End Sub

    Private Sub PanelBtnBulkTag_Click(sender As Object, e As EventArgs) Handles PanelBtnBulkTag.Click
        Call TagBulkWords()
        'Call CreateShort()


        'Call CreateAllStrs()
        'MessageBox.Show("Short Strings Created")
    End Sub

    Private Sub BtnClearCW_Click(sender As Object, e As EventArgs) Handles BtnClearCW.Click
        ListCW.ClearSelected()
    End Sub

    Private Sub BtnClearAbi_Click(sender As Object, e As EventArgs) Handles BtnClearAbi.Click
        ListAbi.ClearSelected()
    End Sub

    Private Sub BtnClearCap_Click(sender As Object, e As EventArgs) Handles BtnClearCap.Click
        ListCap.ClearSelected()
    End Sub

    Private Sub BtnClearGlass_Click(sender As Object, e As EventArgs) Handles BtnClearGlass.Click
        ListGlass.ClearSelected()
    End Sub

    Private Sub BtnClearTvi_Click(sender As Object, e As EventArgs) Handles BtnClearTvi.Click
        ListTvi.ClearSelected()
    End Sub

    Private Sub BtnClearBulk_Click(sender As Object, e As EventArgs) Handles BtnClearBulk.Click
        ListBulk.ClearSelected()
    End Sub

    Private Sub ListCW_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListCW.SelectedIndexChanged
        CBCWSelectedItems.Items.Clear()
        Dim items = ListCW.SelectedItems.OfType(Of String).ToArray()
        CBCWSelectedItems.Items.AddRange(items)
    End Sub

    Private Sub CBCWSelectedItems_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CBCWSelectedItems.SelectedIndexChanged
        Dim selectedIndex As Integer
        selectedIndex = CBCWSelectedItems.SelectedIndex
        Dim selectedItem As Object
        selectedItem = CBCWSelectedItems.SelectedItem
        DataGridView1.DataSource = GetMatrixData(selectedItem.ToString())

    End Sub

    Public Sub DataGroupCallStrings()

        DataGridViewStringsCW.DataSource = GetDataStrings("Smmt")
        DataGridViewStringsCW.Refresh()
        DataGridViewStringsAbi.DataSource = GetDataStrings("Abi")
        DataGridViewStringsAbi.Refresh()
        DataGridViewStringsCap.DataSource = GetDataStrings("Cap")
        DataGridViewStringsCap.Refresh()
        DataGridViewStringsGlass.DataSource = GetDataStrings("Glass")
        DataGridViewStringsGlass.Refresh()
        DataGridViewStringsTvi.DataSource = GetDataStrings("Tvi")
        DataGridViewStringsTvi.Refresh()


        LBLDescCountCW.Text = "CW Short Desc Words: " & DataGridViewStringsCW.RowCount.ToString()

        LBLDescCountAbi.Text = "Abi Short Desc Words: " & DataGridViewStringsAbi.RowCount.ToString()

        LBLDescCountCap.Text = "Cap Short Desc Words: " & DataGridViewStringsCap.RowCount.ToString()

        LBLDescCountGlass.Text = "Glass Short Desc Words: " & DataGridViewStringsGlass.RowCount.ToString()

        LBLDescCountTvi.Text = "Tvi Short Desc Words: " & DataGridViewStringsTvi.RowCount.ToString()

    End Sub
    Public Sub DataGroupCallStringsBulk()

        DataGridViewStringsBulk.DataSource = GetBulkDataStrings()
        DataGridViewStringsBulk.Refresh()
        LBLDescCountAll.Text = "Short Desc Words: " & DataGridViewStringsBulk.RowCount.ToString()

    End Sub
    Public Sub DataGroupCallBulk()
        ListBulk.DataSource = GetDataBulk().AsEnumerable().Select(Function(r) r.Field(Of String)("Word")).ToList()
        LblBulkCount.Text = "Words to Tag: " & ListBulk.Items.Count
    End Sub
    Public Sub DataGroupCallRemain()
        DataGridViewRemain.DataSource = GetBulkDataStringsRemain()
        DataGridViewRemain.Refresh()
        LblCountRemain.Text = "Full Strings Remaining: " & DataGridViewRemain.RowCount.ToString()
    End Sub
    Public Sub DataGroupCall()

        ListCW.DataSource = GetData("Smmt").AsEnumerable().Select(Function(r) r.Field(Of String)("Word")).ToList()
        LBLCountCW.Text = "CW Words to Tag: " & ListCW.Items.Count
        ListAbi.DataSource = GetData("Abi").AsEnumerable().Select(Function(r) r.Field(Of String)("Word")).ToList()
        LBLCountAbi.Text = "Abi Words to Tag: " & ListAbi.Items.Count
        ListCap.DataSource = GetData("Cap").AsEnumerable().Select(Function(r) r.Field(Of String)("Word")).ToList()
        LBLCountCap.Text = "Cap Words to Tag: " & ListCap.Items.Count
        ListGlass.DataSource = GetData("Glass").AsEnumerable().Select(Function(r) r.Field(Of String)("Word")).ToList()
        LBLCountGlass.Text = "Glass Words to Tag: " & ListGlass.Items.Count
        ListTvi.DataSource = GetData("Tvi").AsEnumerable().Select(Function(r) r.Field(Of String)("Word")).ToList()
        LBLCountTvi.Text = "Tvi Words to Tag: " & ListTvi.Items.Count

    End Sub

    Private Sub CBCWBulkSelectedItems_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CBCWBulkSelectedItems.SelectedIndexChanged
        Dim selectedIndex As Integer
        selectedIndex = CBCWBulkSelectedItems.SelectedIndex
        Dim selectedItem As Object
        selectedItem = CBCWBulkSelectedItems.SelectedItem
        DataGridView2.DataSource = GetMatrixData(selectedItem.ToString())
    End Sub

    Private Sub ListBulk_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBulk.SelectedIndexChanged
        CBCWBulkSelectedItems.Items.Clear()
        Dim items = ListBulk.SelectedItems.OfType(Of String).ToArray()
        CBCWBulkSelectedItems.Items.AddRange(items)
    End Sub

    Private Sub OpShortDescCarsAll_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescCarsAll.CheckedChanged
        DataGroupCallStringsBulk()
    End Sub

    Private Sub OpShortDescBikesAll_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescBikesAll.CheckedChanged
        DataGroupCallStringsBulk()
    End Sub

    Private Sub OpShortDescLcvAll_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescLcvAll.CheckedChanged
        DataGroupCallStringsBulk()
    End Sub

    Private Sub OpShortDescOthersAll_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescOthersAll.CheckedChanged
        DataGroupCallStringsBulk()
    End Sub

    Private Sub OpShortDescCarsLcvOthersAll_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescCarsLcvOthersAll.CheckedChanged
        DataGroupCallStringsBulk()
    End Sub

    Private Sub OpShortDescBikesQuadsAll_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescBikesQuadsAll.CheckedChanged
        DataGroupCallStringsBulk()
    End Sub
    Private Sub OpShortDescAllAll_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescAllAll.CheckedChanged
        DataGroupCallStringsBulk()
    End Sub

    Private Sub OpShortDescCars_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescCars.CheckedChanged
        Call DataGroupCallStrings()

    End Sub

    Private Sub OpShortDescBikes_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescBikes.CheckedChanged
        Call DataGroupCallStrings()
    End Sub

    Private Sub OpShortDescLcv_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescLcv.CheckedChanged
        Call DataGroupCallStrings()
    End Sub

    Private Sub OpShortDescOthers_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescOthers.CheckedChanged
        Call DataGroupCallStrings()
    End Sub

    Private Sub OpShortDescCarsLcvOthers_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescCarsLcvOthers.CheckedChanged
        Call DataGroupCallStrings()
    End Sub

    Private Sub OpShortDescBikesQuads_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescBikesQuads.CheckedChanged
        Call DataGroupCallStrings()
    End Sub

    Private Sub OpShortDescAll_CheckedChanged(sender As Object, e As EventArgs) Handles OpShortDescAll.CheckedChanged
        Call DataGroupCallStrings()
    End Sub

    Private Sub OpCar_CheckedChanged(sender As Object, e As EventArgs) Handles OpCar.CheckedChanged
        Call DataGroupCall()
    End Sub

    Private Sub OPBike_CheckedChanged(sender As Object, e As EventArgs) Handles OPBike.CheckedChanged
        Call DataGroupCall()
    End Sub

    Private Sub OPLcv_CheckedChanged(sender As Object, e As EventArgs) Handles OPLcv.CheckedChanged
        Call DataGroupCall()
    End Sub

    Private Sub OpOthers_CheckedChanged(sender As Object, e As EventArgs) Handles OpOthers.CheckedChanged
        Call DataGroupCall()
    End Sub

    Private Sub OpSupCarLcvOther_CheckedChanged(sender As Object, e As EventArgs) Handles OpSupCarLcvOther.CheckedChanged
        Call DataGroupCall()
    End Sub

    Private Sub OpSupBikeQuad_CheckedChanged(sender As Object, e As EventArgs) Handles OpSupBikeQuad.CheckedChanged
        Call DataGroupCall()
    End Sub

    Private Sub OpAll_CheckedChanged(sender As Object, e As EventArgs) Handles OpAll.CheckedChanged
        Call DataGroupCall()
    End Sub

    Private Sub OPBikeBulk_CheckedChanged(sender As Object, e As EventArgs) Handles OPBikeBulk.CheckedChanged
        Call DataGroupCallBulk()
    End Sub

    Private Sub OPLcvBulk_CheckedChanged(sender As Object, e As EventArgs) Handles OPLcvBulk.CheckedChanged
        Call DataGroupCallBulk()
    End Sub

    Private Sub OpOthersBulk_CheckedChanged(sender As Object, e As EventArgs) Handles OpOthersBulk.CheckedChanged
        Call DataGroupCallBulk()
    End Sub

    Private Sub OpSupCarLcvOtherBulk_CheckedChanged(sender As Object, e As EventArgs) Handles OpSupCarLcvOtherBulk.CheckedChanged
        Call DataGroupCallBulk()
    End Sub

    Private Sub OpSupBikeQuadBulk_CheckedChanged(sender As Object, e As EventArgs) Handles OpSupBikeQuadBulk.CheckedChanged
        Call DataGroupCallBulk()
    End Sub

    Private Sub OpAllBulk_CheckedChanged(sender As Object, e As EventArgs) Handles OpAllBulk.CheckedChanged
        Call DataGroupCallBulk()
    End Sub

    Private Sub OpCarBulk_CheckedChanged(sender As Object, e As EventArgs) Handles OpCarBulk.CheckedChanged
        Call DataGroupCallBulk()
    End Sub

    Private Sub OpCarRemain_CheckedChanged(sender As Object, e As EventArgs) Handles OpCarRemain.CheckedChanged
        Call DataGroupCallRemain()
    End Sub

    Private Sub OpBikeRemain_CheckedChanged(sender As Object, e As EventArgs) Handles OpBikeRemain.CheckedChanged
        Call DataGroupCallRemain()
    End Sub

    Private Sub OpOtherRemain_CheckedChanged(sender As Object, e As EventArgs) Handles OpOtherRemain.CheckedChanged
        Call DataGroupCallRemain()
    End Sub

    Private Sub OpCarLcvOtherRemain_CheckedChanged(sender As Object, e As EventArgs) Handles OpCarLcvOtherRemain.CheckedChanged
        Call DataGroupCallRemain()
    End Sub

    Private Sub OpBikeQuadRemain_CheckedChanged(sender As Object, e As EventArgs) Handles OpBikeQuadRemain.CheckedChanged
        Call DataGroupCallRemain()
    End Sub

    Private Sub OpAllRemain_CheckedChanged(sender As Object, e As EventArgs) Handles OpAllRemain.CheckedChanged
        Call DataGroupCallRemain()
    End Sub

    Private Sub OpLCVRemain_CheckedChanged(sender As Object, e As EventArgs) Handles OpLCVRemain.CheckedChanged
        Call DataGroupCallRemain()
    End Sub

    Private Sub Panel1_Click(sender As Object, e As EventArgs) Handles Panel1.Click
        MessageBox.Show("Short Strings will be created, click to continue, this process takes about 4 minutes, so wait for the next message after clicking ok")
        LBLShortWork.Visible = True
        Call CreateAllStrs()
        LBLShortWork.Visible = False
        MessageBox.Show("Short Strings Created")

    End Sub

    Private Sub BtnCWDescStrClear_Click(sender As Object, e As EventArgs) Handles BtnCWDescStrClear.Click
        DataGridViewStringsCW.ClearSelection()
    End Sub

    Private Sub BtnAbiDescStrClear_Click(sender As Object, e As EventArgs) Handles BtnAbiDescStrClear.Click
        DataGridViewStringsAbi.ClearSelection()
    End Sub

    Private Sub BtnCapDescStrClear_Click(sender As Object, e As EventArgs) Handles BtnCapDescStrClear.Click
        DataGridViewStringsCap.ClearSelection()
    End Sub

    Private Sub BtnGlassDescStrClear_Click(sender As Object, e As EventArgs) Handles BtnGlassDescStrClear.Click
        DataGridViewStringsGlass.ClearSelection()
    End Sub

    Private Sub BtnTviDescStrClear_Click(sender As Object, e As EventArgs) Handles BtnTviDescStrClear.Click
        DataGridViewStringsTvi.ClearSelection()
    End Sub

    Private Sub OPBulkDescView1_CheckedChanged(sender As Object, e As EventArgs) Handles OPBulkDescView1.CheckedChanged
        DataGroupCallStringsBulk()
    End Sub

    Private Sub OPBulkDescView2_CheckedChanged(sender As Object, e As EventArgs) Handles OPBulkDescView2.CheckedChanged
        DataGroupCallStringsBulk()
    End Sub

    Private Sub OPBulkDescView3_CheckedChanged(sender As Object, e As EventArgs) Handles OPBulkDescView3.CheckedChanged
        DataGroupCallStringsBulk()
    End Sub

    Private Sub OPBulkDescView4_CheckedChanged(sender As Object, e As EventArgs) Handles OPBulkDescView4.CheckedChanged
        DataGroupCallStringsBulk()
    End Sub
End Class

Open in new window

ee.JPG
0
Comment
Question by:PeterBaileyUk
  • 2
3 Comments
 

Author Comment

by:PeterBaileyUk
ID: 41762300
i am not sure how it got marked request for attention, must have hit a wrong key
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 41762344
I often end up adding a private member to the form preventing some events to occur while I am not ready much like this:

private IsLoading as boolean = false
    Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       IsLoading = true
        Dim ctrl As Control = TabControl1
        OPBulkRemainView1.Checked = True
        OPBulkDescView1.Checked = True
        OPDescView1.Checked = True

        LBLBulkWait.Visible = False
        OpAllBulk.Checked = True
        OpTag.Checked = True
        OpBulkTag.Checked = True
        OpAll.Checked = True
        OpShortDescAllAll.Checked = True
        OpShortDescAll.Checked = True
        OpAllRemain.Checked = True
Isloading = false

        Call DataGroupCallBulk()
        Call DataGroupCall()
        Call DataGroupCallStringsBulk()
        Call DataGroupCallStrings()
        Call DataGroupCallRemain()
    End Sub

Open in new window


Once I have this member, I can easily bypass the code of some events:
    Private Sub OpAllRemain_CheckedChanged(sender As Object, e As EventArgs) Handles OpAllRemain.CheckedChanged
     if isloading then return
        Call DataGroupCallRemain()
    End Sub

Open in new window

0
 

Author Closing Comment

by:PeterBaileyUk
ID: 41762380
That is amazing, what a great technique thank you.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now