ValueChanged EventHandler

Oct 1, 2010 at 6:19 PM

I'm trying to do save the location of a cell when the value of a cell is changed and I'm trying to do it with an event, but I haven't found one that fires when the value is changed.

I was wondering if someone knows one.

 

My current code is

 

int column = this.reportViewsGrid.Selection.ActivePosition.Column;
int row = this.reportViewsGrid.Selection.ActivePosition.Row;
if (this.reportViewsGrid[row, column].Tag.ToString() != "Created")
{
    SourceGrid.Cells.Cell cell;
    string[] list = DropDownVariableList(row, column);
    if (list != null)
    {
        SourceGrid.Cells.Editors.ComboBox combo = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
        //combo.Changed += new EventHandler(combo_Changed);
        combo.StandardValues = list;
        combo.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
        combo.Control.DropDownStyle = ComboBoxStyle.DropDownList;
        cell = new SourceGrid.Cells.Cell(dt.Rows[row][column].ToString(), combo);
        this.reportViewsGrid[row, column] = cell;
        
        const int MOUSEEVENTF_LEFTDOWN = 0x02;
        const int MOUSEEVENTF_LEFTUP = 0x04;
        int X = Cursor.Position.X;
        int Y = Cursor.Position.Y;
        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
    }
    this.reportViewsGrid[row, column].Tag = "Created";
}

I was trying to add the combo.changed even handler but it only fires when you change a property, not the value.

 

Any help is greatly appreciated.

Oct 2, 2010 at 10:55 AM

Hi,

I had the same problem and solved it as follows:

 

 ValueChangedEvent valueChangedController = new ValueChangedEvent;
            grid1.Controller.AddController(valueChangedController);

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

                string val = "Value of cell {0} is '{1}'";
                MessageBox.Show(sender.Grid, string.Format(val, sender.Position, sender.Value));
                            }
        }

 
Oct 4, 2010 at 5:10 PM

Thank you, this was exactly what I was looking for.