This project is read-only.

handle cell changed focus in vb.net

Mar 1, 2009 at 1:27 PM
Hi , i've searched documentation, but i'm not been able to find any answer (i'm not too expert...)

how can i handle a changed cell focus event in vb.net?

thanks in advance
Mar 4, 2009 at 10:36 AM
Edited Mar 4, 2009 at 10:37 AM
To do it in C# (VB is pretty similar)

There are a set of events in the ControllerBase you can override

Create your own ControllerBase class in your project

public class CellEvent : SourceGrid.Cells.Controllers.ControllerBase
    {
         public override void OnFocusLeaving(SourceGrid.CellContext sender, EventArgs e)
        {
            base.OnFocusLeaving(sender, e);

            // Do your validation here
        }
    }



Declare this in the grid
CellEvent eventController = new CellEvent();   

and add it to a cell
this[r, c].AddController(eventController);

From the documentation...
Here the list of events that can be used inside a Controller:
  • Mouse: OnMouseDown, OnMouseUp, OnMouseMove, OnMouseEnter, OnMouseLeave
  • Keys: OnKeyUp, OnKeyDown, OnKeyPress
  • Click: OnDoubleClick, OnClick
  • Focus: OnFocusLeaving, OnFocusLeft, OnFocusEntering, OnFocusEntered, CanReceiveFocus
  • Cell Value: OnValueChanging, OnValueChanged
  • Edit: OnEditStarting, OnEditStarted, OnEditEnded