private void dataGridViewCustomCommandBindings_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { var send = sender as DataGridView; var cellText = send?.SelectedCells[e.ColumnIndex]?.Value?.ToString(); if (cellText == null) { cellText = ""; } var command = send.Rows[e.RowIndex].Cells[1].Value?.ToString(); using (var changeKeybindUI = new ChangeKeybindUI(cellText.ToKeybindInfo(command))) { changeKeybindUI.ShowDialog(); this.dataGridViewCustomCommandBindings.EndEdit(); this.dataGridViewCustomCommandBindings.BeginEdit(false); this.dataGridViewCustomCommandBindings.NotifyCurrentCellDirty(true); if (this.dataGridViewCustomCommandBindings.Rows.Count - 1 == customUserCommandBindings.Count) { customUserCommandBindings.RemoveAt(customUserCommandBindings.Count - 1); } customUserCommandBindings.Add(changeKeybindUI.kbi); this.dataGridViewCustomCommandBindings.EndEdit(); } } // User probably clicked on the header, instead of the cell catch (ArgumentOutOfRangeException) { } //System.Diagnostics.Debugger.Break(); }
private void textBox_DoubleClick(object sender, EventArgs e) { using (var changeKeybindUI = new ChangeKeybindUI((sender as TextBox)?.Text.ToKeybindInfo("", sender as TextBox))) { changeKeybindUI.ShowDialog(); } }