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

Handling DataGridViewComboBoxColumn or BindingSource events

I need to know when the user changes the selection in a DataGridViewComboBoxColumn control. The DataGridView control is bound to a DataTable through a BindingSource and TableAdapter.

It seems to me that the BindingSource should be right place to attach an event handler, since it should know when changes are being made.  I can detect a change in the DataGridView's CellValueChanged event but it's awkward and doesn't seem like the best approach.

-- Craig
0
Craig Yellick
Asked:
Craig Yellick
1 Solution
 
SanclerCommented:
I'm not absolutely certain about this, because I don't use BindingSources much, but I think you may find that you're stuck with CellValueChanged (or something else at cell level).  The reason that I say that is that, although with some added bells and whistles, I think the BIndingSource is essentially a wrapper for the CurrencyManager.  And so far as a CurrencyManager is concerned it knows nothing about changes in a datagridview until the ROW is changed.  That is, it is the DataGridView itself that manages cell-by-cell changes on a single row.  It is only when it is clear that editing on that row is complete (usually by the user moving to a different row) that those changes are passed on - as a whole changed row - to the CurrencyManager.

If that still applies with respect to BindingSources (and my - limited - experience with them suggests that it does) then, unless the change is one that you are prepared to leave undetected until the user moves to another row, you will need to use a cell-level event.

Roger
0
 
Craig YellickDatabase ArchitectAuthor Commented:
Thanks. I think you are correct about the level of detail that the currency manager knows about the UI events. I keep thinking that by now the Windows Forms UI subsystem would have a more natural mapping to a model-view-controller design.

-- Craig
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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