diff --git a/src/EncCnvtrs/EncCnvtrs 2010.csproj b/src/EncCnvtrs/EncCnvtrs 2010.csproj index b3e3938..00d67a9 100644 --- a/src/EncCnvtrs/EncCnvtrs 2010.csproj +++ b/src/EncCnvtrs/EncCnvtrs 2010.csproj @@ -309,6 +309,7 @@ NetRegexAutoConfigDialog.cs + Designer ImplTypeList.cs diff --git a/src/EncCnvtrs/NetRegexAutoConfigDialog.Designer.cs b/src/EncCnvtrs/NetRegexAutoConfigDialog.Designer.cs index 3aefd2a..daf553c 100644 --- a/src/EncCnvtrs/NetRegexAutoConfigDialog.Designer.cs +++ b/src/EncCnvtrs/NetRegexAutoConfigDialog.Designer.cs @@ -407,6 +407,7 @@ private void InitializeComponent() this.dataGridViewRegularExpressions.Size = new System.Drawing.Size(380, 160); this.dataGridViewRegularExpressions.TabIndex = 12; this.toolTip.SetToolTip(this.dataGridViewRegularExpressions, resources.GetString("dataGridViewRegularExpressions.ToolTip")); + this.dataGridViewRegularExpressions.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewRegularExpressions_CellContentClick); this.dataGridViewRegularExpressions.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewRegularExpressions_CellEndEdit); this.dataGridViewRegularExpressions.CurrentCellDirtyStateChanged += new System.EventHandler(this.dataGridViewRegularExpressions_CurrentCellDirtyStateChanged); this.dataGridViewRegularExpressions.SelectionChanged += new System.EventHandler(this.dataGridViewRegularExpressions_SelectionChanged); diff --git a/src/EncCnvtrs/NetRegexAutoConfigDialog.cs b/src/EncCnvtrs/NetRegexAutoConfigDialog.cs index 9b6ed55..ed34f6a 100644 --- a/src/EncCnvtrs/NetRegexAutoConfigDialog.cs +++ b/src/EncCnvtrs/NetRegexAutoConfigDialog.cs @@ -384,21 +384,40 @@ private void linkLabelOpenQuickReference_LinkClicked(object sender, LinkLabelLin private int rowIndexFromMouseDown; private int rowIndexOfItemUnderMouseToDrop; - private void dataGridViewRegularExpressions_MouseDown(object sender, MouseEventArgs e) + private void dataGridViewRegularExpressions_MouseDown(object sender, MouseEventArgs e) { - // Get the index of the row to drag - rowIndexFromMouseDown = dataGridViewRegularExpressions.HitTest(e.X, e.Y).RowIndex; - if ((rowIndexFromMouseDown < 0) || (rowIndexFromMouseDown > dataGridViewRegularExpressions.Rows.Count - 2)) - return; - System.Diagnostics.Debug.WriteLine($"Select row index: {rowIndexFromMouseDown}"); + // Get the index of the row to drag + var hitTestInfo = dataGridViewRegularExpressions.HitTest(e.X, e.Y); + rowIndexFromMouseDown = hitTestInfo.RowIndex; + var columnIndex = hitTestInfo.ColumnIndex; + + // make sure it's a valid row and column (don't process DragDrop for checkbox column + // or it won't toggle the Enabled checkbox) + if ((rowIndexFromMouseDown < 0) || (rowIndexFromMouseDown > dataGridViewRegularExpressions.Rows.Count - 2) || + (columnIndex < 0) || dataGridViewRegularExpressions.Columns[columnIndex] is DataGridViewCheckBoxColumn) + { + return; + } - if (rowIndexFromMouseDown != -1) - { - dataGridViewRegularExpressions.DoDragDrop(dataGridViewRegularExpressions.Rows[rowIndexFromMouseDown], DragDropEffects.Move | DragDropEffects.Copy); - } - } + System.Diagnostics.Debug.WriteLine($"Select row index: {rowIndexFromMouseDown}"); + + if ((rowIndexFromMouseDown != -1) && (e.Button == MouseButtons.Left)) + { + dataGridViewRegularExpressions.DoDragDrop(dataGridViewRegularExpressions.Rows[rowIndexFromMouseDown], DragDropEffects.Move | DragDropEffects.Copy); + } + } + + private void dataGridViewRegularExpressions_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // Toggle the checkbox value + var cell = dataGridViewRegularExpressions[e.ColumnIndex, e.RowIndex]; + bool newValue = !(bool)(cell.Value ?? false); // Default to false if null + cell.Value = newValue; + + controlChangedModified(null, null); + } - private void dataGridViewRegularExpressions_DragOver(object sender, DragEventArgs e) + private void dataGridViewRegularExpressions_DragOver(object sender, DragEventArgs e) { // Provide visual feedback during the drag operation Point clientPoint = dataGridViewRegularExpressions.PointToClient(new Point(e.X, e.Y)); @@ -428,6 +447,6 @@ private void dataGridViewRegularExpressions_DragDrop(object sender, DragEventArg IsModified = true; } } - } + } } diff --git a/src/EncCnvtrs/NetRegexAutoConfigDialog.resx b/src/EncCnvtrs/NetRegexAutoConfigDialog.resx index 4581595..5f4c747 100644 --- a/src/EncCnvtrs/NetRegexAutoConfigDialog.resx +++ b/src/EncCnvtrs/NetRegexAutoConfigDialog.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 17, 165 + 635, 17 True @@ -139,10 +139,10 @@ 17, 17 - 17, 91 + 338, 17 - 17, 128 + 448, 17 68