Hi, after problems with using checkedlistboxes and the rest. I decided to take an easier route and use a listbox which i have populated from a database. It contains text with values assigned to it. i also have a DGV with 4 columns. The column i wish to sort by contains integers only.

I am just wondering how i can sort the DGV by passing a value from the listbox.. here is my code:

Private Sub lstCat_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstCat.SelectedIndexChanged
        'MsgBox("you selected " + lstCat.SelectedValue.ToString)
        Dim i As Integer

        i = lstCat.SelectedValue

        'DGVShops.Sort(DGVShops.Columns(1), System.ComponentModel.ListSortDirection.Ascending)
    End Sub

The msgbox was for testing the values are correct.
i is supposed to equal the value of selected index (which is fortunately the same as the CatID will be i want to sort by)

The last line just sorts it in ascending, but i would like to sort the column by whatever given value (2,3,4, etc)

I am also having problems trying to use a textbox to search for a value in the name column.

1. User types "String" into txtbox
2. press ok
3."String" passed to DGV/dataset/bindingsource/what?
4. Datagridview displays reults with "string" in the set column. only.

My main problem is i dont know how to pass the data to, whatever im passing it to. the above problem is similar surely, just using an integer instead of a string.

please help!

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.