zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    python_day11 mysql
    python_day10 多线程 协程 IO模型
    python_day09 多进程 多线程 协程 paramiko模块
    python_day08 接口与归一化设计 多态与多态性 封装 面向对象高级 异常处理 网络编程
    python_day07 常用模块xml/configparser/hashlib/subprocess 面向对象程序设计
    python_day06 匿名函数与内置函数 常用模块
    python_day05 协程函数 面向过程编程 递归和二分法 模块和包的使用 常用模块 开发代码规范
    python_day04 函数嵌套 名称空间和作用域 闭包 装饰器 迭代器 生成器 列表解析 三元表达式 生成器表达式
    python_day03 文件处理复习和函数定义调用参数对象
    python_day02 基本数据类型操作,字符编码,文件处理
  • 原文地址:https://www.cnblogs.com/shangdishijiao/p/12673993.html
Copyright © 2011-2022 走看看