Data Grid View Combo Box Selecting Item so i get the index to search in another Data Grid Combo? RRS feed

  • Question

  • Hi guys I am new to vb.net 2008 and was wondering how do i select from a data grid view combo. The first combo contains my item codes. I want to select an item code and it automatically sets the Description in the other combo or vice versa. I have read some of the articles but getting stuck and failing to grasp the concept. I know there us a simple way of doing this. Please Help
    Wednesday, July 14, 2010 11:05 AM


  • Hi,


    Here is an FAQ about this:

    27. How do I have a combo box column display a sub set of data based upon the value of a different combo box column?


    First, use two datasource (it may be bindingsource). One is the original datasouce and another is used to filter.


    When the dependent combobox cell begins edit, filter the filtering datasource according to the first combobox. Fill this dependent combobox cell with the filtering datasouce. You will see the needed items in the dropdown list.


    All combobox cells value should be in the items collection or else a DataError will be thrown. All combo box cells in the column use the same datasource if you filter the datasource for one row then a combo box cell in another row might not have its value visible in the datasource, thus causing a DataError event.


    So in the cellEndEdit event, change the filtering datasouce back to the original datasource. This will make sure all the value are in the items collection.


    Click that FAQ link for more information about this.


    The following thread shows example code in VB.net:



    Hope this helps.


    Best regards,

    Ling Wang

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Jing0 Friday, July 23, 2010 4:26 AM
    Tuesday, July 20, 2010 8:22 AM