コード例 #1
0
        private void ugvDatos_KeyPress(object sender, KeyPressEventArgs e)
        {
            Infragistics.Win.UltraWinGrid.UltraGrid grid = (sender as Infragistics.Win.UltraWinGrid.UltraGrid);

            Infragistics.Win.UltraWinGrid.UltraGridCell activeCell = grid == null ? null : grid.ActiveCell;

            // if there is an active cell, its not in edit mode and can enter edit mode
            if (null != activeCell && false == activeCell.IsInEditMode && activeCell.CanEnterEditMode)
            {
                // if the character is not a control character
                if (char.IsControl(e.KeyChar) == false)
                {
                    // try to put cell into edit mode
                    grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);

                    // if this cell is still active and it is in edit mode...
                    if (grid.ActiveCell == activeCell && activeCell.IsInEditMode)
                    {
                        // get its editor
                        Infragistics.Win.EmbeddableEditorBase editor = grid.ActiveCell.EditorResolved;

                        // if the editor supports selectable text
                        if (editor.SupportsSelectableText)
                        {
                            // select all the text so it can be replaced
                            editor.SelectionStart  = 0;
                            editor.SelectionLength = editor.TextLength;

                            if (editor is Infragistics.Win.EditorWithMask)
                            {
                                // just clear the selected text and let the grid
                                // forward the keypress to the editor
                                editor.SelectedText = string.Empty;
                            }
                            else
                            {
                                // then replace the selected text with the character
                                editor.SelectedText = new string(e.KeyChar, 1);

                                // mark the event as handled so the grid doesn't process it
                                e.Handled = true;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: frmSettings.cs プロジェクト: razdavidovich/Electra
 /****************************************************************************************************
 * NAME         : call_uGrid_IsInEditMode                                                           *
 * DESCRIPTION  : Call the Trigger for Raise the ExitEditMode Event.                                *
 * WRITTEN BY   : RajaSekar J                                                                       *
 * DATE         : 15Feb2018                                                                           *
 ****************************************************************************************************/
 private void call_uGrid_IsInEditMode(IWUG.UltraGrid uGrid)
 {
     try
     {
         if (uGrid.ActiveCell != null)
         {
             if (uGrid.ActiveCell.IsInEditMode)
             {
                 uGrid.PerformAction(IWIN.UltraWinGrid.UltraGridAction.ExitEditMode);
             }
         }
     }
     catch (Exception ex)
     {
         string str = ex.Message;
     }
 }
        private void txtControl_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtSearch
            if (sender == txtSearch)
            {
                if (e.KeyCode == Keys.Tab)
                {
                    MessageBox.Show("Tab");
                    Grid.Focus();
                    return;
                }
            }
            #endregion

            #region Grid
            if (sender == Grid)
            {
                if (e.KeyCode == Keys.Tab)
                {
                    txtSearch.Focus();
                    return;
                }
            }
            #endregion


            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Up:
                if (Grid.Focused)
                {
                    if (Grid.Rows.Count == 0)
                    {
                    }
                    else if (Grid.ActiveRow == Grid.Rows[0])
                    {
                        txtSearch.Focus();
                    }
                    else
                    {
                        Grid.PerformAction(UltraGridAction.AboveCell, false, false);
                    }
                }
                e.Handled = true;
                break;

            case Keys.Down:
                if (txtSearch.Focused && Grid.Rows.Count > 0)
                {
                    Grid.Focus();
                }
                Grid.PerformAction(UltraGridAction.BelowCell, false, false);
                e.Handled = true;

                break;

            case Keys.Right:
                //UltraGrid1.PerformAction(ExitEditMode, False, False)
                Grid.PerformAction(UltraGridAction.NextCellByTab, false, false);
                e.Handled = true;
                //UltraGrid1.PerformAction(EnterEditMode, False, False)
                break;

            case Keys.Left:
                //UltraGrid1.PerformAction(ExitEditMode, False, False)
                Grid.PerformAction(UltraGridAction.PrevCellByTab, false, false);
                e.Handled = true;
                //UltraGrid1.PerformAction(EnterEditMode, False, False)
                break;

            case Keys.Enter:
                DataGrid_MouseUp(null, null);
                e.Handled = true;
                break;
            }
            #endregion
        }
        private void txtControl_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtSearch
            if (sender == txtSearch)
            {
                if (e.KeyCode == Keys.Tab)
                {
                    Grid.Focus();
                    return;
                }
                if (e.KeyCode == Keys.Enter)
                {
                    if (Grid.Rows.Count > 0)
                    {
                        UltraGridRow aUGRow = Grid.Rows[0];
                        Grid.ActiveRow = aUGRow;
                        if (Grid.ActiveRow != null)
                        {
                            SelectedID = Grid.ActiveRow.Cells["Teacher"].Text;
                            CustomerID = Grid.ActiveRow.Cells["CustomerID"].Text;
                        }
                        this.Close();
                    }
                    else
                    {
                        this.Close();
                    }

                    return;
                }
            }
            #endregion

            #region Grid
            if (sender == Grid)
            {
                if (e.KeyCode == Keys.Tab)
                {
                    txtSearch.Focus();
                    return;
                }
                if (e.KeyCode == Keys.Enter)
                {
                    if (Grid.Rows.Count > 0)
                    {
                        if (Grid.ActiveRow != null)
                        {
                            SelectedID = Grid.ActiveRow.Cells["Teacher"].Text;
                            CustomerID = Grid.ActiveRow.Cells["CustomerID"].Text;
                        }

                        this.Close();
                    }

                    return;
                }
            }
            #endregion

            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Up:
                if (Grid.Focused)
                {
                    if (Grid.Rows.Count == 0)
                    {
                    }
                    else if (Grid.ActiveRow == Grid.Rows[0])
                    {
                        txtSearch.Focus();
                    }
                    else
                    {
                        Grid.PerformAction(UltraGridAction.AboveCell, false, false);
                    }
                }
                e.Handled = true;
                break;

            case Keys.Down:
                if (txtSearch.Focused && Grid.Rows.Count > 0)
                {
                    Grid.Focus();
                }
                Grid.PerformAction(UltraGridAction.BelowCell, false, false);
                e.Handled = true;

                break;

            case Keys.Right:
                //UltraGrid1.PerformAction(ExitEditMode, False, False)
                Grid.PerformAction(UltraGridAction.NextCellByTab, false, false);
                e.Handled = true;
                //UltraGrid1.PerformAction(EnterEditMode, False, False)
                break;

            case Keys.Left:
                //UltraGrid1.PerformAction(ExitEditMode, False, False)
                Grid.PerformAction(UltraGridAction.PrevCellByTab, false, false);
                e.Handled = true;
                //UltraGrid1.PerformAction(EnterEditMode, False, False)
                break;

            case Keys.Enter:
                DataGrid_MouseUp(null, null);
                e.Handled = true;
                break;
            }
            #endregion
        }
コード例 #5
0
        private void ugvDatos_KeyDown(object sender, KeyEventArgs e)
        {
            Infragistics.Win.UltraWinGrid.UltraGrid dgvDatos = (sender as Infragistics.Win.UltraWinGrid.UltraGrid);
            switch (e.KeyCode)
            {
            case Keys.Up:
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode, false,
                                       false);
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.AboveCell, false,
                                       false);
                e.Handled = true;
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false,
                                       false);
                break;

            case Keys.Down:
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode, false,
                                       false);
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.BelowCell, false,
                                       false);
                e.Handled = true;
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false,
                                       false);
                break;

            case Keys.Right:
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode, false,
                                       false);
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextCellByTab, false,
                                       false);
                e.Handled = true;
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false,
                                       false);
                break;

            case Keys.Left:
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode, false,
                                       false);
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.PrevCellByTab, false,
                                       false);
                e.Handled = true;
                dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false,
                                       false);
                break;
            }
        }
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtProductID
            if (sender == txtProductID)
            {
                if (e.KeyCode.ToString() == "F8")
                {
                    this.Grid.Focus();
                }

                if (e.KeyCode.ToString() == "F2")
                {
                    if (oOrder.oProduct.View(oOrder.oCustomer))
                    {
                        this.txtProductID.Text = oOrder.oProduct.ID;
                        return;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtProductID.Text == "DONE")
                    {
                        txtProductID.Clear();
                        txtCollected.Enabled = true;
                        txtCollected.Focus();
                        return;
                    }


                    if ((txtProductID.Text.Length == 12 && oOrder.oProduct.FindByBarcode(txtProductID.Text)) || oOrder.oProduct.Find(txtProductID.Text))
                    {
                        Boolean HasBrochure = false;
                        foreach (BrochureByCustomer bc in oOrder.oCustomer.Brochures)
                        {
                            if (oOrder.oProduct.IsInBrochure(bc.BrochureID))
                            {
                                HasBrochure = true;
                                break;
                            }
                        }
                        if (!HasBrochure)
                        {
                            Global.playSimpleSound();
                            txtDescription.Text = "This Product Belongs to Other Brochure";
                            return;
                        }


                        this.IDetail.ProductID   = oOrder.oProduct.ID;
                        this.IDetail.Price       = oOrder.oProduct.ExtendedPrice(oOrder.oCustomer);
                        this.IDetail.Description = oOrder.oProduct.Description.ToString();
                        this.IDetail.Length      = oOrder.oProduct.Length;
                        this.IDetail.Width       = oOrder.oProduct.Width;
                        this.IDetail.Height      = oOrder.oProduct.Height;

                        this.txtProductID.Text   = oOrder.oProduct.ID;
                        this.txtDescription.Text = oOrder.oProduct.Description;



                        AddItem();
                        ActiveRow();
                        txtProductID.Focus();
                    }
                    else
                    {
                        Global.playSimpleSound();
                    }
                    this.txtProductID.Focus();
                    this.txtProductID.Clear();
                    return;
                }
            }
            #endregion

            #region txtCollected
            if (sender == this.txtCollected)
            {
                if (oOrder.Collected != txtCollected.Number)
                {
                    oOrder.Collected = txtCollected.Number;
                    getTotals();
                }

                if (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.Return)
                {
                    if (!oOrder.oCustomer.Find(CustomerID))
                    {
                        MessageBox.Show("Please enter a valid Customer ID/School ID ");
                        return;
                    }

                    if (Math.Abs(oOrder.Diff) > 0 && !IsDiff)
                    {
                        Global.playSimpleSound();
                        IsDiff = true;
                    }
                    else
                    {
                        IsDiff = false;
                    }

                    Save();
                    Clear();
                    txtCollected.Enabled = false;
                    txtProductID.Focus();
                    return;
                }
            }
            #endregion

            #region Grid
            if (sender == this.Grid)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (Grid.ActiveRow != null)
                    {
                        if (Grid.ActiveCell != null)
                        {
                            if (!Grid.ActiveCell.IsInEditMode)
                            {
                                //' set ActiveCell
                                Grid.ActiveCell = Grid.ActiveRow.Cells["Quantity"];
                                Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                                return;
                            }
                            else
                            {
                                Grid.PerformAction(UltraGridAction.ExitEditMode, true, true);
                                return;
                            }
                        }
                        else
                        {
                            Grid.ActiveCell = Grid.ActiveRow.Cells["Quantity"];
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                            return;
                        }
                    }
                }

                if (e.KeyCode == Keys.Down)
                {
                    Grid.PerformAction(UltraGridAction.BelowRow, false, false);
                    return;
                }
                if (e.KeyCode == Keys.Up)
                {
                    Grid.PerformAction(UltraGridAction.AboveRow, false, false);
                    return;
                }


                /*
                 * if (e.KeyCode.ToString()=="Delete")
                 *             {
                 *                     this.DeleteItem(false);
                 *                     return;
                 *             }*/
                if (e.KeyCode.ToString() == "F8")
                {
                    this.txtProductID.Focus();
                    return;
                }
            }

            #endregion

            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Tab:
                if (!e.Shift)
                {
                    this.SelectNextControl(this.ActiveControl, true, true, true, true);
                }
                break;

            case Keys.Enter:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Down:

                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Up:

                this.SelectNextControl(this.ActiveControl, false, true, true, true);
                break;

            case Keys.F8:
                this.Grid.Focus();
                break;

            case Keys.F5:
            {
                Clear();
                txtProductID.Focus();
            }

            break;

            case Keys.F12:
            {
                oOrder.Find(oOrder.GetLastID());
                ShowOrder();
            }

            break;

            case Keys.F3:
                deleteOrder();
                break;

            case Keys.PageDown:
                this.Save();
                txtProductID.Clear();
                txtCollected.Enabled = true;
                txtCollected.Focus();
                return;

                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
        private void gKits_KeyUp(object sender, KeyEventArgs e)
        {
            if (sender == gKits)
            {
                if (e.KeyCode == Keys.Tab)
                {
                    txtSearch.Focus();
                    return;
                }
                if (e.KeyCode == Keys.Enter)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow            = gKits.ActiveRow;
                    gridRow.Appearance = gKits.DisplayLayout.Appearances["Normal"];
                    gridRow            = gridRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Next);
                    if (gridRow != null)
                    {
                        gridRow.Activate();
                        //' set ActiveCell
                        gKits.ActiveCell = gKits.ActiveRow.Cells["Quantity"];
                        gKits.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                        gridRow.Appearance = gKits.DisplayLayout.Appearances["Credit"];
                    }

                    //SendKeys.Send("{TAB}");
                }
                if (e.KeyCode == Keys.Down)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow            = gKits.ActiveRow;
                    gridRow.Appearance = gKits.DisplayLayout.Appearances["Normal"];
                    gridRow            = gridRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Next);
                    if (gridRow != null)
                    {
                        gridRow.Activate();
                        //' set ActiveCell
                        gKits.ActiveCell = gKits.ActiveRow.Cells["Quantity"];
                        gKits.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                        gridRow.Appearance = gKits.DisplayLayout.Appearances["Credit"];
                    }

                    //SendKeys.Send("{TAB}");
                }
                if (e.KeyCode == Keys.Up)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow            = gKits.ActiveRow;
                    gridRow.Appearance = gKits.DisplayLayout.Appearances["Normal"];
                    gridRow            = gridRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Previous);
                    if (gridRow != null)
                    {
                        gridRow.Activate();
                        //' set ActiveCell
                        gKits.ActiveCell = gKits.ActiveRow.Cells["Quantity"];
                        gKits.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                        gridRow.Appearance = gKits.DisplayLayout.Appearances["Credit"];
                    }

                    //SendKeys.Send("{TAB}");
                }
            }
        }
コード例 #8
0
        private void dgvArticulos_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                Infragistics.Win.UltraWinGrid.UltraGrid dgvDatos = (sender as Infragistics.Win.UltraWinGrid.UltraGrid);
                UltraGrid     grid       = sender as UltraGrid;
                UltraGridCell activeCell = grid == null ? null : grid.ActiveCell;

                switch (e.KeyCode)
                {
                case Keys.Up:

                    dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode, false,
                                           false);
                    dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.AboveCell, false,
                                           false);
                    e.Handled = true;
                    dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false,
                                           false);
                    break;

                case Keys.Down:
                    dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode, false,
                                           false);
                    dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.BelowCell, false,
                                           false);
                    e.Handled = true;
                    dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false,
                                           false);
                    break;

                case Keys.Right:
                    if (grid.ActiveCell == activeCell /*&& !activeCell.IsInEditMode*/)
                    {
                        dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode, false,
                                               false);
                        dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextCellByTab, false,
                                               false);
                        e.Handled = true;
                        dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false,
                                               false);
                    }
                    break;

                case Keys.Left:
                    if (grid.ActiveCell == activeCell /*&& !activeCell.IsInEditMode*/)
                    {
                        dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode, false,
                                               false);
                        dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.PrevCellByTab, false,
                                               false);
                        e.Handled = true;
                        dgvDatos.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false,
                                               false);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }