• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 723
  • Last Modified:

DataGridView and ComboBox inside

I am trying to create an order form and on my DataGridView I want a column for product and a column for price. The DataGridView is not bound to anything, and neither is the combobox in the datagrid for products. I have the combobox get loaded at runtime. I am looking for a way that I can read when the user has selected an item in the combobox and then be able to insert the appropriate price into the price column. All I need to know is the selectedIndex of the combobox, not even the value because the selected index would correspond to the row in the dataset for the price.

Thank you
Chris
0
nyk52687
Asked:
nyk52687
1 Solution
 
Bob LearnedCommented:
Have you seen the DataGridViewComboBoxColumn?

DataGridViewComboBoxColumn.Items Property
http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcolumn.items.aspx

Bob
0
 
nyk52687Author Commented:
I know that part. I am looking mainly for:
A) How to detect when a product is selected from the combobox
B) How to retrieve the zero-based index of the selection in the combobox (like the SelectedIndex of a regular combobox).

If the user selected the first item in the list, I want to see that something was selected and return that it was the item in index 0.

Chris
0
 
Bob LearnedCommented:
The DataGridViewComboBoxColumn only has 1 event (Disposed), so I don't think that you can detect when the value is changed.

Bob
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
nyk52687Author Commented:
What would you suggest would allow me to accomplish this? Would a regular DataGrid work better or maybe a 3rd party tool?

Chris
0
 
hatem72Commented:

    Private Sub dataGridView1_EditingControlShowing(ByVal sender As Object, _
    ByVal e As DataGridViewEditingControlShowingEventArgs) _
    Handles DataGridView1.EditingControlShowing

        Dim cbox As ComboBox = e.Control

        Debug.Print(cbox.SelectedValue.ToString)

    End Sub
0
 
kasowitzCommented:
I also had this same question..

hatem72, seems like this is on the right track...Anyone to designate a certain ComboBox? It looks to be grabbing the text from any ComboBox in the entire DataGridView.

Maybe I just need explained what that code is actually doing.

Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now