Exemplo n.º 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;
            }
        }
Exemplo n.º 2
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;
        }