Ejemplo n.º 1
0
        private void dgvContacts_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            // Get currentRow.
            DataGridViewRow currentRow = dgvContacts.CurrentRow;
            ContactObj      contact    = ChatTwo_Client_Protocol.Contacts.Find(x => x.ID == (int)currentRow.Cells["dgvContactsId"].Value);

            ChatTwo_Client_Protocol.OpenChat((int)currentRow.Cells["dgvContactsId"].Value);
        }
Ejemplo n.º 2
0
        private void dgvContacts_KeyDown(object sender, KeyEventArgs e)
        { // Based on: http://stackoverflow.com/questions/1718389/right-click-context-menu-for-datagrid.
            DataGridView     dgv         = (sender as DataGridView);
            DataGridViewCell currentCell = dgv.CurrentCell;

            if (currentCell != null)
            {
                cmsContactList_Opening(null, null);
                if ((e.KeyCode == Keys.F10 && !e.Control && e.Shift) || e.KeyCode == Keys.Apps)
                {
                    dgv.ContextMenuStrip = cmsContactList;
                    Rectangle r = currentCell.DataGridView.GetCellDisplayRectangle(currentCell.ColumnIndex, currentCell.RowIndex, false);
                    Point     p = new Point(r.X + r.Width, r.Y + r.Height);
                    dgv.ContextMenuStrip.Show(currentCell.DataGridView, p);
                    dgv.ContextMenuStrip = null;
                }
                else if (e.KeyCode == Keys.Enter && !e.Control && !e.Shift && !e.Alt)
                {
                    ChatTwo_Client_Protocol.OpenChat((int)dgv.Rows[currentCell.RowIndex].Cells["dgvContactsId"].Value);
                }
            }
        }