473,388 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

using the DataGridViewComboBoxColumn object

I have tried to use the DataGridComboBoxColumn object with limited success.
What I want to do is to create one new unbound column to be a combo box (so
far, this has worked), populate it with items from the database (this also
has worked). But, now I want to be able to have the user select one of the
items in that combo box and fire off an event to select more data from the
database based on what the user selected in the combo box.

Well, this DataGrid version of the combo box is very different from the
regular version. The big this is that I cannot figure out what event is fired
when the user selects a combo box item and how one gets to the selected value
in that combo box.. Normally one would go to the ComboBox.SelectedValue (or
is it SelectedIndex?) and there you go. There is not such property, and I
have not figured out which DataGridView event to use to make this happen. Can
anyone help? Thank you.

Ed Cohen

Oct 31 '08 #1
1 5301
you need to get the column which is set to be a combo box like this

DataGridViewComboBoxColumn col = dataGridView1.Columns[1] as
DataGridViewComboBoxColumn;
if(null != col)
{
//do your processing here
}

Secondly, in cases like this, you have these values set

col.DataSource = laneTypeTable; //name of the table
col.ValueMember = "LaneID"; // this field is used for value internally
col.DisplayMember = "Name"; //this is used for display only

For the event part, you can register for ColumnChanging event of the
table which you are displaying in the grid.

Thanks & Regards,
Ashutosh Bhawasinka

Ed Cohen wrote:
I have tried to use the DataGridComboBoxColumn object with limited success.
What I want to do is to create one new unbound column to be a combo box (so
far, this has worked), populate it with items from the database (this also
has worked). But, now I want to be able to have the user select one of the
items in that combo box and fire off an event to select more data from the
database based on what the user selected in the combo box.

Well, this DataGrid version of the combo box is very different from the
regular version. The big this is that I cannot figure out what event is fired
when the user selects a combo box item and how one gets to the selected value
in that combo box.. Normally one would go to the ComboBox.SelectedValue (or
is it SelectedIndex?) and there you go. There is not such property, and I
have not figured out which DataGridView event to use to make this happen. Can
anyone help? Thank you.

Ed Cohen

Oct 31 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Shawn | last post by:
I am trying to use a DataGridView to display one column of textboxes with a single value from a query and then next to it have a combobox that displays results from another query. What happens is...
3
by: philip | last post by:
I have a datagridview with some columns. One of them has been declared as a DatagridviewComboboxColumn The datasource of this column is a table of an Access Database. There is 13000 lines in...
3
by: Rain County | last post by:
I am programmatically building and populating a table and then making it the data source for a dataGridView. I want to add a column to the dataGridView which will be a DataGridViewComboBoxColumn. ...
4
by: John | last post by:
Hi, I've been trying to populate a DataGridViewComboBoxColumn with objects. The object is defined as : private struct manufactItem { public string name; public Guid? man_id;
1
by: Garland | last post by:
Hi, I have a DataGridViewComboBoxColumn. This column displays a list of options to the user. It does not allow the user to enter a selection that is not in the list of options. dropdown style...
0
by: Simon Tamman | last post by:
How do other people get around having to define the ValueMember in a DataGridViewComboBoxColumn when binding to a list of business objects? I'm currently doing the following, and it feels wrong...
1
by: sklett | last post by:
I have a DataGridView bound to a custom business object. The business object has 2 attributes that are FKs to a lookup table (think HairColorID, EyeColorID, etc) For these 2 columns I have...
0
by: anureddy | last post by:
help me how to add datagridview columns to another table,using windowsapplications. and set the displaymember and value member datagridviewcomboboxcolumn. i used this below code but that not...
0
by: ajey | last post by:
hi all! Im doing a windows application (C#), i have a datagridview bound from a Sql database in which i want one column to be ComboBox.I use DataGridViewComboBoxColumn and bind that column value.......
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.