'绑定不同按钮
Private Sub dataView__CellPainting(sender As Object, e As DataGridViewCellPaintingEventArgs) Handles dataView.CellPainting
If e.ColumnIndex >= 0 And e.RowIndex >= 0 Then
If (dataView.Columns(e.ColumnIndex).HeaderText = "操作") Then
Dim index = e.RowIndex
'dataView.Rows(index).Cells(0).Value, dataView.Rows(index).Cells(2).Value)
If dataView.Rows(index).Cells("orderState").Value = 1 Then
dataView.Rows(index).Cells("btnOperate").Style.NullValue = "查看进度"
End If
If dataView.Rows(index).Cells("orderState").Value = 2 Then
dataView.Rows(index).Cells("btnOperate").Style.NullValue = "查看进度"
End If
If dataView.Rows(index).Cells("orderState").Value = 4 Then
dataView.Rows(index).Cells("btnOperate").Style.NullValue = "确认"
End If
'已确认
If dataView.Rows(index).Cells("orderState").Value = 8 Then
dataView.Rows(index).Cells("btnOperate").Style.NullValue = "结果查看"
dataView.Rows(index).Cells("btnOperate").Tag = "结果查看"
End If
'套料
If dataView.Rows(index).Cells("orderState").Value = 16 Then
dataView.Rows(index).Cells("btnOperate").Style.NullValue = "等待套料"
dataView.Rows(index).Cells("btnOperate").Tag = "等待套料"
End If
'取消
If dataView.Rows(index).Cells("orderState").Value = 32 Then
dataView.Rows(index).Cells("btnOperate").Style.NullValue = "重新套料"
dataView.Rows(index).Cells("btnOperate").Tag = "重新套料"
End If
'dataView.Rows(index).Cells(e.ColumnIndex).ContentBounds.
'Dim sf As StringFormat = CType(StringFormat.GenericDefault.Clone(), StringFormat) ';//设置重绘入单元格的字体样式
'sf.FormatFlags = StringFormatFlags.DisplayFormatControl
'sf.Alignment = StringAlignment.Center
'sf.LineAlignment = StringAlignment.Center
'sf.Trimming = StringTrimming.EllipsisCharacter
'e.PaintBackground(e.CellBounds, False) ';//重绘边框
'Dim gdiCharSet As Byte = CType(134, Byte)
''设置要写入字体的大小
'Dim myFont As System.Drawing.Font = New System.Drawing.Font("宋体", 9.0F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, gdiCharSet)
'Dim sizeDel As SizeF = e.Graphics.MeasureString("删除", myFont)
'Dim sizeMod As SizeF = e.Graphics.MeasureString("修改", myFont)
'Dim sizeLook As SizeF = e.Graphics.MeasureString("查看", myFont)
'Dim fDel As Double = sizeDel.Width / (sizeDel.Width + sizeMod.Width + sizeLook.Width)
'Dim fMod = sizeMod.Width / (sizeDel.Width + sizeMod.Width + sizeLook.Width)
'Dim fLook = sizeLook.Width / (sizeDel.Width + sizeMod.Width + sizeLook.Width)
''设置每个“按钮的边界”
'Dim rectDel As RectangleF = New RectangleF(e.CellBounds.Left, e.CellBounds.Top, e.CellBounds.Width * fDel, e.CellBounds.Height)
'Dim rectMod = New RectangleF(rectDel.Right, e.CellBounds.Top, e.CellBounds.Width * fMod, e.CellBounds.Height)
'Dim rectLook = New RectangleF(rectMod.Right, e.CellBounds.Top, e.CellBounds.Width * fLook, e.CellBounds.Height)
'e.Graphics.DrawString("删除", myFont, Brushes.Black, rectDel, sf) '; //绘制“按钮”
'e.Graphics.DrawString("修改", myFont, Brushes.Black, rectMod, sf) ';
'e.Graphics.DrawString("查看", myFont, Brushes.Black, rectLook, sf) ';
'e.Handled = True
'e.RowIndex
End If
End If
End Sub