コード例 #1
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.Enter)
            {
                if (dataGridView1.CurrentRow == null)
                {
                    return(true);
                }

                int CurIndex = dataGridView1.CurrentRow.Index;

                if (MessageBox.Show(string.Format("Vil du oprette en ordre til {0} {1}", dataGridView1.CurrentRow.Cells[0].Value.ToString(), dataGridView1.CurrentRow.Cells[1].Value.ToString()), "Ny Ordre", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    fmSalesOrderHeader soh = new fmSalesOrderHeader(dataGridView1.CurrentRow.Cells[0].Value.ToString(), true, dtItems, dtSearchItems);
                    soh.ShowDialog();
                }

                dataGridView1.CurrentCell = dataGridView1.Rows[CurIndex].Cells[0];

                return(true);
            }

            if (keyData == Keys.Escape)
            {
                this.Close();
            }
            return(base.ProcessCmdKey(ref msg, keyData));
        }
コード例 #2
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.Enter)
            {
                if (dataGridView1.CurrentRow == null)
                {
                    return(true);
                }


                if (dataGridView1.CurrentRow.Cells[0].Value != null)
                {
                    int CurIndex = dataGridView1.CurrentRow.Index;

                    fmSalesOrderHeader so = new fmSalesOrderHeader(dataGridView1.CurrentRow.Cells[0].Value.ToString(), dtItems, dtSearchItems);
                    so.ShowDialog();
                    GetOrderList();

                    if ((dataGridView1.Rows.Count - 1) < CurIndex)
                    {
                        CurIndex--;
                    }
                    if (CurIndex >= 0)
                    {
                        dataGridView1.CurrentCell = dataGridView1.Rows[CurIndex].Cells[0];
                    }
                }
                return(true);
            }

            if (keyData == Keys.Escape)
            {
                this.Close();
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }