Exemplo n.º 1
0
 private void PlayOnForm(object sender, EventArgs e, DataGridView.HitTestInfo testResult)
 {
     AudioIn.Play(dataGridView1.Rows[testResult.RowIndex].Cells[2].Value.ToString(), float.Parse(VolumeIn.Value.ToString()) / 100);
     AudioOut.Play(dataGridView1.Rows[testResult.RowIndex].Cells[2].Value.ToString(), float.Parse(VolumeOut.Value.ToString()) / 100);
 }
Exemplo n.º 2
0
 private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
 {
     hti = ((DataGridView)sender).HitTest(e.X, e.Y);
 }
Exemplo n.º 3
0
 private void StopOnForm(object eventSender, EventArgs eventArgs, DataGridView.HitTestInfo testResult)
 {
     AudioIn.Stop();
     AudioOut.Stop();
 }
Exemplo n.º 4
0
        /// <summary>
        /// 显示右键
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void krpdgList_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            //右键
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (e.RowIndex == -1 || null == krpdgList.Rows[e.RowIndex] || krpdgList.RowCount == 0)
                {
                    kryptonContextMenuItemSave.Enabled   = false;
                    kryptonContextMenuItemDelete.Enabled = false;
                }
                else
                {
                    // 没行选中时判断一下, 是否单击了空的地方, 如果是则只显示新增之类的
                    if (krpdgList.Rows[e.RowIndex].Selected == false)
                    {
                        DataGridView.HitTestInfo hit = krpdgList.HitTest(e.X, e.Y);
                        if (hit.Type == DataGridViewHitTestType.None)
                        {
                            return;
                        }
                        else
                        {
                            ExitEditMode();

                            krpdgList.Rows[e.RowIndex].Selected = true;
                            if (krpdgList.SelectedRows.Count == 0)
                            {
                                return;
                            }
                        }
                    }
                    else
                    {
                        ExitEditMode();

                        krpdgList.Rows[e.RowIndex].Selected = true;
                        if (krpdgList.SelectedRows.Count == 0)
                        {
                            return;
                        }
                    }


                    //如果有改动才可以保存
                    if (krpdgList.SelectedRows[0].Cells["krpcmEdit"].Value.Equals("*"))
                    {
                        kryptonContextMenuItemSave.Enabled = true;

                        // 只有还没保存的才能删除
                        if (krpdgList.SelectedRows[0].Cells["krpcmAdminPayId"].Value.ToString() == "-1")
                        {
                            kryptonContextMenuItemDelete.Enabled = true;
                        }
                    }
                }
                kryptonContextMenuItemAdd.Enabled = true;
                //显示
                krpContextMenu.Show(krpdgList.RectangleToScreen(krpdgList.ClientRectangle),
                                    KryptonContextMenuPositionH.Left, KryptonContextMenuPositionV.Top);
            }
        }
        private void dgvListagem_MouseDown(object sender, MouseEventArgs e)
        {
            // check button
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            Control c = (Control)sender;

            DataGridView.HitTestInfo hit = dgvListagem.HitTest(e.X, e.Y);
            dgvListagem.ClearSelection();

            if (hit.Type != DataGridViewHitTestType.Cell)
            {
                return;
            }

            // seleciona o ROW
            dgvListagem.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dgvListagem.CurrentCell   = dgvListagem.Rows[hit.RowIndex].Cells[2];
            dgvListagem.Rows[hit.RowIndex].Selected = true;

            // mostra o MENU ativar e desativar
            objAReceber recItem = (objAReceber)dgvListagem.Rows[hit.RowIndex].DataBoundItem;

            // mnuVerPagamentos
            mnuItemEstornar.Enabled = recItem.ValorRecebido > 0;

            switch (recItem.IDSituacao)
            {
            case 1:                     // EM ABERTO
                mnuItemAlterar.Enabled    = true;
                mnuItemAlterar.Text       = "Alterar";
                mnuItemCancelar.Enabled   = true;
                mnuItemNormalizar.Enabled = false;
                mnuItemReceber.Enabled    = true;
                mnuItemEstornar.Enabled   = false;
                break;

            case 2:                     // RECEBIDAS
                mnuItemAlterar.Enabled    = false;
                mnuItemCancelar.Enabled   = false;
                mnuItemNormalizar.Enabled = false;
                mnuItemReceber.Enabled    = false;
                mnuItemEstornar.Enabled   = true;
                break;

            case 3:                     // CANCELADAS
                mnuItemAlterar.Enabled    = false;
                mnuItemCancelar.Enabled   = false;
                mnuItemNormalizar.Enabled = true;
                mnuItemReceber.Enabled    = false;
                mnuItemEstornar.Enabled   = false;
                break;

            default:
                break;
            }

            // revela menu
            mnuOperacoes.Show(c.PointToScreen(e.Location));
        }
Exemplo n.º 6
0
 private void tblwfaklinDataGridView1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         DataGridView.HitTestInfo hit = tblwfaklinDataGridView.HitTest(e.X, e.Y);
         int hitcol = hit.ColumnIndex;
         if (hit.Type == DataGridViewHitTestType.Cell && hit.ColumnIndex == 2)
         {
             tblwfaklinDataGridView.ClearSelection();
             DataGridViewCell cellVarenr = tblwfaklinDataGridView.Rows[hit.RowIndex].Cells[hit.ColumnIndex];
             cellVarenr.Selected = true;
             Point       startPoint    = tblwfaklinDataGridView.PointToScreen(new Point(e.X, e.Y));
             FrmVareList m_frmVareList = new FrmVareList(startPoint);
             m_frmVareList.ShowDialog();
             int?selectedVarenr = m_frmVareList.SelectedVarenr;
             m_frmVareList.Close();
             if (selectedVarenr != null)
             {
                 tblwfak    recWfak    = tblwfakBindingSource.Current as tblwfak;
                 tblwfaklin recWfaklin = ((DataGridView)sender).Rows[hit.RowIndex].DataBoundItem as tblwfaklin;
                 if (recWfaklin != null)
                 {
                     try
                     {
                         recVarer rec = (from k in Program.karVarer where k.Varenr == selectedVarenr select k).First();
                         recWfaklin.varenr = rec.Varenr.ToString();
                         recWfaklin.tekst  = rec.Varenavn;
                         recWfaklin.enhed  = rec.Enhed;
                         if (recWfak.sk == "S")
                         {
                             recWfaklin.konto    = rec.Salgskonto;
                             recWfaklin.momskode = KarKontoplan.getMomskode(rec.Salgskonto);
                             recWfaklin.pris     = rec.Salgspris;
                         }
                         if (recWfak.sk == "K")
                         {
                             recWfaklin.konto    = rec.Kobskonto;
                             recWfaklin.momskode = KarKontoplan.getMomskode(rec.Kobskonto);
                             recWfaklin.pris     = rec.Kobspris;
                         }
                     }
                     catch { }
                 }
             }
         }
         else if (hit.Type == DataGridViewHitTestType.Cell && hit.ColumnIndex == 4)
         {
             tblwfaklinDataGridView.ClearSelection();
             tblwfaklinDataGridView.Rows[hit.RowIndex].Cells[hit.ColumnIndex].Selected = true;
             Point            startPoint         = tblwfaklinDataGridView.PointToScreen(new Point(e.X, e.Y));
             FrmKontoplanList m_frmKontoplanList = new FrmKontoplanList(startPoint, KontoType.Drift | KontoType.Status);
             m_frmKontoplanList.ShowDialog();
             int?   selectedKontonr  = m_frmKontoplanList.SelectedKontonr;
             string selectedMomskode = m_frmKontoplanList.SelectedMomskode;
             m_frmKontoplanList.Close();
             if (selectedKontonr != null)
             {
                 tblwfaklin recWfaklin = ((DataGridView)sender).Rows[hit.RowIndex].DataBoundItem as tblwfaklin;
                 if (recWfaklin != null)
                 {
                     recWfaklin.konto    = selectedKontonr;
                     recWfaklin.momskode = selectedMomskode;
                 }
             }
         }
         else if (hit.Type == DataGridViewHitTestType.RowHeader)
         {
             this.contextMenuLineCopyPaste.Show(this.tblwfaklinDataGridView, new Point(e.X, e.Y));
         }
     }
 }
 private int GetRowUnderCursor(Point location)
 {
     myHitTest = _View.HitTest(location.X, location.Y);
     return(myHitTest.RowIndex);
 }