예제 #1
0
        //fire the bool change event if the value changes
        private void ManageBoolValueChanging(int rowNum, int colNum)
        {
            Point    mousePos      = this.DataGridTableStyle.DataGrid.PointToClient(Control.MousePosition);
            DataGrid dg            = this.DataGridTableStyle.DataGrid;
            bool     isClickInCell = ((Control.MouseButtons == MouseButtons.Left) &&
                                      dg.GetCellBounds(dg.CurrentCell).Contains(mousePos));

            bool changing = dg.Focused && (isClickInCell ||
                                           GetKeyState(VK_SPACE) < 0); // or spacebar

            if (!lockValue && beingEdited && changing && saveRow == rowNum)
            {
                saveValue = !saveValue;
                lockValue = false;

                //fire the event
                if (BoolValueChanged != null)
                {
                    BoolValueChangedEventArgs e = new BoolValueChangedEventArgs(rowNum, colNum, saveValue);
                    BoolValueChanged(this, e);
                }
            }
            if (saveRow == rowNum)
            {
                lockValue = false;
            }
        }
예제 #2
0
 private void BoolValueChanged(object sender, BoolValueChangedEventArgs e)
 {
     this.dataGrid1.EndEdit(this.dataGrid1.TableStyles[0].GridColumnStyles["Discontinued"], e.Row, false);
     RefreshRow(e.Row);
     this.dataGrid1.BeginEdit(this.dataGrid1.TableStyles[0].GridColumnStyles["Discontinued"], e.Row);
 }