From d17e1183f9374f110bd7e8b0ceef81f3ff546af4 Mon Sep 17 00:00:00 2001 From: Frozd <59323943+frozdbyte@users.noreply.github.com> Date: Fri, 28 Nov 2025 13:08:18 +0100 Subject: [PATCH] feat: keybinds --- CarManagerV2/CarDetailsForm.Designer.cs | 16 ++++++++-------- CarManagerV2/CarDetailsForm.cs | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CarManagerV2/CarDetailsForm.Designer.cs b/CarManagerV2/CarDetailsForm.Designer.cs index f5b7a7d..8241a08 100644 --- a/CarManagerV2/CarDetailsForm.Designer.cs +++ b/CarManagerV2/CarDetailsForm.Designer.cs @@ -118,7 +118,7 @@ this.tbxMake.Location = new System.Drawing.Point(68, 203); this.tbxMake.Name = "tbxMake"; this.tbxMake.Size = new System.Drawing.Size(473, 22); - this.tbxMake.TabIndex = 2; + this.tbxMake.TabIndex = 1; this.tbxMake.TextChanged += new System.EventHandler(this.tbxMake_TextChanged); // // label2 @@ -136,7 +136,7 @@ this.tbxModel.Location = new System.Drawing.Point(68, 233); this.tbxModel.Name = "tbxModel"; this.tbxModel.Size = new System.Drawing.Size(473, 22); - this.tbxModel.TabIndex = 4; + this.tbxModel.TabIndex = 2; this.tbxModel.TextChanged += new System.EventHandler(this.tbxModel_TextChanged); // // label3 @@ -194,7 +194,7 @@ this.btnSave.Location = new System.Drawing.Point(450, 8); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(75, 23); - this.btnSave.TabIndex = 0; + this.btnSave.TabIndex = 7; this.btnSave.Text = "Save"; this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); @@ -204,7 +204,7 @@ this.btnDelete.Location = new System.Drawing.Point(369, 8); this.btnDelete.Name = "btnDelete"; this.btnDelete.Size = new System.Drawing.Size(75, 23); - this.btnDelete.TabIndex = 1; + this.btnDelete.TabIndex = 8; this.btnDelete.Text = "Delete"; this.btnDelete.UseVisualStyleBackColor = true; this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); @@ -228,7 +228,7 @@ 0}); this.nudYear.Name = "nudYear"; this.nudYear.Size = new System.Drawing.Size(120, 22); - this.nudYear.TabIndex = 10; + this.nudYear.TabIndex = 3; this.nudYear.ValueChanged += new System.EventHandler(this.nudYear_ValueChanged); // // tbxColor @@ -237,7 +237,7 @@ this.tbxColor.Location = new System.Drawing.Point(68, 293); this.tbxColor.Name = "tbxColor"; this.tbxColor.Size = new System.Drawing.Size(473, 22); - this.tbxColor.TabIndex = 11; + this.tbxColor.TabIndex = 4; this.tbxColor.TextChanged += new System.EventHandler(this.tbxColor_TextChanged); // // nudMileage @@ -250,7 +250,7 @@ 0}); this.nudMileage.Name = "nudMileage"; this.nudMileage.Size = new System.Drawing.Size(120, 22); - this.nudMileage.TabIndex = 12; + this.nudMileage.TabIndex = 5; this.nudMileage.ThousandsSeparator = true; this.nudMileage.ValueChanged += new System.EventHandler(this.nudMileage_ValueChanged); // @@ -265,7 +265,7 @@ 0}); this.nudPrice.Name = "nudPrice"; this.nudPrice.Size = new System.Drawing.Size(120, 22); - this.nudPrice.TabIndex = 13; + this.nudPrice.TabIndex = 6; this.nudPrice.ThousandsSeparator = true; this.nudPrice.ValueChanged += new System.EventHandler(this.nudPrice_ValueChanged); // diff --git a/CarManagerV2/CarDetailsForm.cs b/CarManagerV2/CarDetailsForm.cs index 6015d19..6da9119 100644 --- a/CarManagerV2/CarDetailsForm.cs +++ b/CarManagerV2/CarDetailsForm.cs @@ -94,5 +94,24 @@ namespace CarManagerV2 } } + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) + { + if (keyData == Keys.Enter) + { + btnSave.PerformClick(); + return true; // Indicate that the key has been handled + } + if (keyData == Keys.Escape) + { + this.Close(); + return true; // Indicate that the key has been handled + } + if (keyData == Keys.Delete) + { + btnDelete.PerformClick(); + return true; // Indicate that the key has been handled + } + return base.ProcessCmdKey(ref msg, keyData); + } } }