?
Solved

DataGridView and ComboBox inside

Posted on 2006-04-18
9
Medium Priority
?
717 Views
Last Modified: 2012-06-27
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
Comment
Question by:nyk52687
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16481439
Have you seen the DataGridViewComboBoxColumn?

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

Bob
0
 

Author Comment

by:nyk52687
ID: 16481649
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
 
LVL 96

Expert Comment

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

Bob
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:nyk52687
ID: 16481798
What would you suggest would allow me to accomplish this? Would a regular DataGrid work better or maybe a 3rd party tool?

Chris
0
 
LVL 6

Accepted Solution

by:
hatem72 earned 300 total points
ID: 16488280

    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
 

Expert Comment

by:kasowitz
ID: 16565159
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

839 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