Adding grid Selection.CellLostFocus event does not cause firing

Jun 20, 2012 at 5:46 PM

I am trying to receive an event, when a user leaves a cell.

In the form's constructor, I added the following line:

this.ctlTable.Selection.CellLostFocus += new SourceGrid.ChangeActivePositionEventHandler(Selection_CellLostFocus);

ctlTable is the name of the grid control and Selection_CellLostFocus() is the name of the event handler that I created.

The problem that I have is that I never receive any events.

What is wrong?

Thanks in advance,


Jun 21, 2012 at 12:10 PM

Difficult to say what is the problem without seeing the code. One problem might be that you change selection mode after attaching event. Changing selection mode actually re-instantiates selection class, and thus loses all your events

You can take sample 26 as example, and add an event like that at line 148

grid1.Selection.CellLostFocus += delegate {  MessageBox.Show("Hello world");     };


Jun 22, 2012 at 6:23 PM

You were/are absolutely correct.  The problem was indeed the underlying code resetting things, so I lost everything.  I was initializing the SelectionMode later on.

If you ask me, that is a bug in the codebase, but okay, at least I know about it as well as anyone else reading this thread.

Jun 25, 2012 at 10:35 AM

Yeah, I would agree that this is completely unwanted feature/bug.  I would be happy to get rid of it, though that requires some refactoring to do it properly.

Jun 26, 2012 at 3:11 PM
Edited Jun 26, 2012 at 3:11 PM

Does that mean that there is a live developer of this product? :-)

Jun 27, 2012 at 9:02 AM
sweinberger wrote:

Does that mean that there is a live developer of this product? :-)

Not necessarily :)