• VB net 表格绑定不同按钮


        '绑定不同按钮
        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
  • 相关阅读:
    【OC 知识】静态变量
    【OC知识点】alloc 和init
    【oc 知识点】copy和mutableCopy
    【iOS入门】pod 安装
    【iOS入门】NSarray
    【iOS入门】instancetype和id的区别
    【iOS入门】不全屏
    【ios入门】xcode 新建项目变化
    Spark(一)-- Standalone HA的部署
    数据挖掘算法之协同过滤算法
  • 原文地址:https://www.cnblogs.com/shangdishijiao/p/12673993.html
Copyright © 2020-2023  润新知