er.daljeetsingh 0 Newbie Poster

i have a datagridview with checkboxes in my window form and i want to sort my result with textbox without losting checkbox checked value. i place code in textbox_textchange() event.

first i fill datatable with label click()

Private Sub Label8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label8.Click

cmd = New OracleCommand("select categoryname from subcategory  where doctype='" + glbdocid + "'order by categoryname ASC ", dl.con)
            dim myDataTable as new DataTable
            adap = New OracleDataAdapter(cmd)
            adap.Fill(DataTable)
            DataGridView1.DataSource=myDataTable
End Sub



Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged

Dim myDataView As New DataView(myDataTable)

myDataView.RowFilter = "Categoryname LIKE '%" & TextBox9.Text & "%'"
myDataView.Sort = "categoryname"
dataGridView1.DataSource = myDataView
dataGridView1.DataBind() 

EndSub

And i get all checkbox checked value with comma saprate in Textbox6


 Private Sub TextBox6_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox6.GotFocus
        Dim j As Integer
        Dim str1 As String
        Dim s As Integer
        s = 0
        str1 = ""
        For j = 0 To DataGridView1.Rows.Count - 1
       
            If DataGridView1.Item(0, j).Value = True Then
                If s = 0 Then
                    str1 = DataGridView1.Item(1, j).Value.ToString()
                    s = 1
                Else
                    str1 = str1 + "," + DataGridView1.Item(1, j).Value.ToString()
                End If

            End If

        Next
        Panel1.Visible = False
        TextBox6.Text = str1
       
    End Sub

but i didn't get exact result what i want....plase help me to sort out this problem.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.