Results 1 to 4 of 4

Thread: DatagridviewComboBoxColumn Dynamically populating items collection

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    36

    Question DatagridviewComboBoxColumn Dynamically populating items collection

    Hi,

    I am trying to create a basic quoting tool but got stuck on how to clear and change the item collection from within a combobox for a datagrid.

    What we have is a list of 4 columns like
    a. Device b.TypeofService c.State d.Price
    Inside a sql database. Data is also structure like above as well.

    I have a datagridview where the user will populate a,b,c and the price will be display and a total at the end. However a,b, and c aren't related in my current application. The combobox will show all possible dinstinct values for each column.

    This works fine but I want to refine the application to only show the values of b. which are in the database after the user select the value for a. I have tried searching on how to do this as I assume to the Contry/State/City situation but could not find anything for a datagridview control in VB.NET.

    Can anyone point me in the right direction? If I cannot do this dynamically from within a datagridview I was thinking of maybe creating three combo box outside and having it populating the datagridview afterwards but it wouldn't be as nice.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DatagridviewComboBoxColumn Dynamically populating items collection

    You will need to handle the EditingControlShowing event of the grid. In the event handler, you can get access to the row and column indexes and the ComboBox control itself, so you can determine what should be shown and then show it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    36

    Re: DatagridviewComboBoxColumn Dynamically populating items collection

    I am using these event handlers to calculate the price. However I have no idea how to clear the items colection for one row and update it with new values. I dont want to update the items collection for all prrevious column calues as it might alter the perviously populated rows.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DatagridviewComboBoxColumn Dynamically populating items collection

    All you're changing is the items in the ComboBox being used to edit the current cell.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width