Browse Source

是否可以点击内容勾选添加属性设置

章政 7 years ago
parent
commit
11f0555106

+ 28 - 8
UAS-MES/CustomControl/DataGrid_View/DataGridViewWithSerialNum.cs

@@ -13,6 +13,22 @@ namespace UAS_MES.CustomControl.DataGrid_View
     public partial class DataGridViewWithSerialNum : DataGridView
     {
         SolidBrush solidBrush;
+
+        bool EnableContentClick1 = true;
+
+        public bool EnableContentClick
+        {
+            get
+            {
+                return EnableContentClick1;
+            }
+
+            set
+            {
+                EnableContentClick1 = value;
+            }
+        }
+
         public DataGridViewWithSerialNum()
         {
             InitializeComponent();
@@ -27,24 +43,28 @@ namespace UAS_MES.CustomControl.DataGrid_View
 
         private void DataGridViewWithSerialNum_CellContentClick(object sender, DataGridViewCellEventArgs e)
         {
-            if (Columns[0] is DataGridViewCheckBoxColumn && e.ColumnIndex >= 0 && e.RowIndex >= 0)
+            if (EnableContentClick1)
             {
-                if (!(Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn)&&!(Columns[e.ColumnIndex] is DataGridViewComboBoxColumn))
+                if (Columns[0] is DataGridViewCheckBoxColumn && e.ColumnIndex >= 0 && e.RowIndex >= 0)
                 {
-                    if (Rows[e.RowIndex].Cells[0].Value != null)
+                    if (!(Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn) && !(Columns[e.ColumnIndex] is DataGridViewComboBoxColumn))
                     {
-                        if (Rows[e.RowIndex].Cells[0].Value.ToString() == "0")
+                        if (Rows[e.RowIndex].Cells[0].Value != null)
                         {
-                            Rows[e.RowIndex].Cells[0].Value = 1;
+                            if (Rows[e.RowIndex].Cells[0].Value.ToString() == "0")
+                            {
+                                Rows[e.RowIndex].Cells[0].Value = 1;
+                            }
+                            else
+                            {
+                                Rows[e.RowIndex].Cells[0].Value = 0;
+                            }
                         }
                         else
                         {
                             Rows[e.RowIndex].Cells[0].Value = 0;
                         }
                     }
-                    else {
-                        Rows[e.RowIndex].Cells[0].Value = 0;
-                    }
                 }
             }
         }

+ 1 - 0
UAS-MES/FunctionCode/OQC/OQC_CheckNoSplit.Designer.cs

@@ -220,6 +220,7 @@
             this.obd_makecode,
             this.obd_sncode,
             this.obd_builddate});
+            this.OutBoxDGV.EnableContentClick = false;
             this.OutBoxDGV.Location = new System.Drawing.Point(39, 281);
             this.OutBoxDGV.Name = "OutBoxDGV";
             this.OutBoxDGV.RowTemplate.Height = 27;