Browse Source

指定列添加颜色

章政 8 years ago
parent
commit
f10b6ef631

+ 1 - 0
UAS-MES/FunctionCode/Make/Make_PositionStock.Designer.cs

@@ -288,6 +288,7 @@
             this.BatchProductDGV.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.BatchProduct_CellContentClick);
             this.BatchProductDGV.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.BatchProductDGV_CellEndEdit);
             this.BatchProductDGV.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.BatchProductDGV_CellFormatting);
+            this.BatchProductDGV.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.BatchProductDGV_CellPainting);
             // 
             // sp_soncode
             // 

+ 18 - 0
UAS-MES/FunctionCode/Make/Make_PositionStock.cs

@@ -296,5 +296,23 @@ namespace UAS_MES.Make
         {
             Screen.PerformClick();
         }
+
+        private void BatchProductDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
+        {
+            bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
+            if (e.ColumnIndex > 0)
+            {
+                if (BatchProductDGV.Columns[e.ColumnIndex].Name == "mss_remain")
+                {
+                    SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
+                    e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.LightSeaGreen, e.CellBounds);
+                    Rectangle border = e.CellBounds;
+                    border.Width -= 1;
+                    e.Graphics.DrawRectangle(Pens.White, border);
+                    e.PaintContent(e.CellBounds);
+                    e.Handled = true;
+                }
+            }
+        }
     }
 }