473,387 Members | 1,517 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,387 software developers and data experts.

Detecting selection change in ComboBox column of a DataGridView

Hello,

I have an unbound DataGridView of which one of the columns is a ComboBox
colum containing category data, plus an additional option called <newSo
when the ComboBox is dropped down it looks like this

<new>
First
Second
Third
Fourth

I would like to add an event to this ComboBox so that I can detect if the
user chooses <newor not. I have tried various combinations of the very
rich DataGridView event model e.g. the CellValueChanged event. The problem
with this is that it doesn't fire when the ComboBox itself changes - it only
fires when the contents of the underlying cell changes i.e. when the user
moves to another cell.

I found this via Google
http://forums.microsoft.com/MSDN/Sho...54048&SiteID=1

but I can't get it to work. It seems to have been written using a beta
version of .NET2 so maybe things were changed in the released version.

I'm wondering if what I'm trying to achieve is even possible? Is it possible
to grab the ComboBox in a ComboBox column and wire up new events for it?

Thanks in advance.

DJ
Apr 14 '07 #1
2 20207
"David Jackson" <so*****@somewhere.comwrote in message
news:Ou**************@TK2MSFTNGP02.phx.gbl...
I'm wondering if what I'm trying to achieve is even possible? Is it
possible to grab the ComboBox in a ComboBox column and wire up new events
for it?
It most certainly is. This MSDN article shows you how:
http://msdn2.microsoft.com/en-us/lib...ngcontrol.aspx
Apr 14 '07 #2
David Jackson schreef:
Hello,

I have an unbound DataGridView of which one of the columns is a ComboBox
colum containing category data, plus an additional option called <newSo
when the ComboBox is dropped down it looks like this

<new>
First
Second
Third
Fourth

I would like to add an event to this ComboBox so that I can detect if the
user chooses <newor not. I have tried various combinations of the very
rich DataGridView event model e.g. the CellValueChanged event. The problem
with this is that it doesn't fire when the ComboBox itself changes - it only
fires when the contents of the underlying cell changes i.e. when the user
moves to another cell.
Subscribe to the EditingControlShowing event.. Verify if the control is
a ComboBox and if it is, subscribe to it's SelectionChangeCommitted event:

ComboBox cbo = e.Control as ComboBox;
if (cbo != null) {
cbo.SelectionChangeCommitted += ...;
}
In that handler you simply write the values back to the binding:
foreach(Binding binding in comboBox.DataBindings) {
binding.WriteValue();
}
--
Tim Van Wassenhove <url:http://www.timvw.be/>
Apr 14 '07 #3

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

Similar topics

5
by: Lynn C | last post by:
I have a combobox column in a datagrid. (I am using the example from Geoge Shepard's website on deriving a custom column style from DataGridTextBoxColumn). The problem I am having is when you make a...
0
by: Michel Lapointe | last post by:
Hello, I would like to know if there is an event for the Datagridview control that is trigger before the selection change and is cancelable. I'm currently using the SelectionChanged event...
4
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone...
3
by: sklett | last post by:
I'm changing from a DataGrid to a DataGridView and have run across a problem. The items that are bound to the DataGrid have an int Property that represents a primary key of a lookup table in my...
1
by: Ananthu | last post by:
Hi I have combobox column in datagridview.I have loaded a particular database table column value into it from my mysql database. The combobox in all the rows is filled with my database value...
3
by: Motawee | last post by:
i am making a windows form application that contains a datagridview that is filled with employees names the program is for the attendance absence holidays of employees in the company so i...
0
by: priyamtheone | last post by:
There's an editable datagridview populated from a table say tblItems. Among the columns of the datagridview there's a combobox column named 'Category'. This column is populated by the respective...
0
by: Moorthi chinna | last post by:
how to reload combobox in datagridview based on combobox selection in datagridview?
1
by: Hardy123 | last post by:
Hi, I am having a combobox column in a datagridview named "dgcProfessor" which contains the list of professors names. i am filling that column with a datatable Now that datatable have more than...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.