Database/DataGrid/Listboxes - how to link together?

Posted on 2004-11-15
Last Modified: 2010-04-23
I've got a form with a datagrid and a few listboxes on it.
The DataGrid is connected to the DataSet
The ListBoxes are connected to fields in the same table as the DataGrid.
When I change records by clicking on the DataGrid the listboxes dont change to reflect the data in the current record.

How can I make the listboxes update to reflect the current record when the DataGrid record changes?
Question by:Matrix1000
    1 Comment
    LVL 1

    Accepted Solution

    Dim currentrow, currentcell As Integer
    currentrow = DataGrid1.CurrentRowIndex
    currentcell = DataGrid1.CurrentCell.ColumnNumber
    ListBox1.SelectedIndex =DataGrid1.Item(currentrow, 0)
    ListBox2.SelectedIndex =DataGrid1.Item(currentrow, 1)

    if the value of the listboxes' selectedindex is not displayed in the datagrid, you could put them in the datagrid and make it invisible.


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    728 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

    18 Experts available now in Live!

    Get 1:1 Help Now