Winform让DataGridView左侧显示图片

作者:秦风 时间:2021-09-24 03:50:38 

效果图片

Winform让DataGridView左侧显示图片

重写DataGridView的OnRowPostPaint方法或者直接在DataGridView的RowPostPaint事件里写,如下(重写DataGridView的OnRowPostPaint方法)


using System;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace Test
{
 class DataGridViewEx : DataGridView
 {
   SolidBrush solidBrush;
   public DataGridViewEx()
   {
     solidBrush = new SolidBrush(this.RowHeadersDefaultCellStyle.ForeColor);
   }

protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
   {
     e.Graphics.DrawImage(Image对象, e.RowBounds.Location.X, e.RowBounds.Location.Y); base.OnRowPostPaint(e);
   }
 }
}
标签:DataGridView
0
投稿

猜你喜欢

  • Java应用多机器部署解决大量定时任务问题

    2023-10-28 17:07:17
  • Java获取视频时长、大小的示例

    2023-01-16 01:48:44
  • 关于访问后端接口报404错误问题的解决方法(全网最细!)

    2022-02-13 23:18:40
  • 解析Java的设计模式编程之解释器模式的运用

    2022-01-04 04:02:18
  • 一文带你搞懂Redis分布式锁

    2021-09-26 12:56:14
  • java 用itext设置pdf纸张大小操作

    2022-10-09 15:00:43
  • java实现顺时针打印矩阵

    2023-06-26 19:17:22
  • java中final与finally的使用介绍

    2023-04-21 05:36:43
  • Java中的ThreadLocal详解

    2023-01-02 16:02:21
  • Mybatis注解增删改查的实例代码

    2022-03-31 01:26:15
  • Java中break、continue、return在for循环中的使用

    2023-03-21 23:36:05
  • Java线程池大小的设置方法实例

    2022-10-04 04:20:19
  • SpringBoot瘦身打包部署的实现

    2021-09-09 16:54:21
  • Spring Boot 2.7.6整合redis与低版本的区别

    2023-11-11 19:44:56
  • 彻底掌握C语言strcpy函数的用法

    2023-07-03 07:21:18
  • 在eclipse中中文汉字乱码的解决方案

    2023-11-25 10:13:27
  • Spring项目中使用Junit单元测试并配置数据源的操作

    2022-06-02 05:32:27
  • Java全面深入探究SpringBoot拦截器与文件上传

    2021-11-12 20:08:24
  • Java SpringBoot实现AOP

    2023-05-31 05:49:30
  • 手动模拟JDK动态代理的方法

    2023-03-23 00:49:03
  • asp之家 软件编程 m.aspxhome.com