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的OnRowPostPaint方法,希望能给大家一个参考,也希望大家多多支持我们。
相关推荐
-
C# WinForm控件对透明图片重叠时出现图片不透明的简单解决方法
本文实例讲述了C# WinForm控件对透明图片重叠时出现图片不透明的简单解决方法.分享给大家供大家参考,具体如下: 在Winform中如果将一个透明图片放在窗体上能正常显示透明,但是如果将该图片放在另一个控件上会导致不能显示透明效果. 解决这种情况,可以采取在控件上使用GDI+绘画出透明图片. 这里我们就以一个pictureBox2控件上面重叠一张png透明图片为例: 我们只需要给pictureBox2控件添加Paint事件,然后对png透明图片进行绘制即可,代码如下: private voi
-
C#实现winform中RichTextBox在指定光标位置插入图片的方法
本文实例讲述了C#实现winform中RichTextBox在指定光标位置插入图片的方法.分享给大家供大家参考,具体如下: //获取RichTextBox控件中鼠标焦点的索引位置 int startPosition = this.richTextBox1.SelectionStart; //从鼠标焦点处开始选中几个字符 this.richTextBox1.SelectionLength = 2; //清空剪切板,防止里面之前有内容 Clipboard.Clear(); //给剪切板设置图片对象
-
Winform 显示Gif图片的实例代码
复制代码 代码如下: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Diagnostics; namespace DysncPicTest{ public par
-
Winform下实现图片切换特效的方法
本文实例讲述了Winform下实现图片切换特效的方法,是应用程序开发中非常实用的一个功能.分享给大家供大家参考之用.具体方法如下: 本实例源自网络,功能较为齐全.丰富!主要功能代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Drawin
-
基于C# winform实现图片上传功能的方法
本文所述实例实现将一张图片上传到指定的文件夹,然后在窗体上的PictrueBox控件中显示出来. 具体功能代码如下: private void btnUpload_Click(object sender, EventArgs e) { //创建一个对话框对象 OpenFileDialog ofd = new OpenFileDialog(); //为对话框设置标题 ofd.Title = "请选择上传的图片"; //设置筛选的图片格式 ofd.Filter = "图片格式|*
-
winform壁纸工具为图片添加当前月的日历信息
这几天用winform做了一个设置壁纸的小工具, 为图片添加当月的日历并设为壁纸,可以手动设置壁纸,也可以定时设置壁纸,最主要的特点是在图片上生成当前月的日历信息. 工具和桌面设置壁纸后的效果如下: 在图片上画日历的类代码Calendar.cs如下: 复制代码 代码如下: using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.IO; using
-
Winform在DataGridView中显示图片
首先,要添加图片列,绑定数据的时候会触发CellFormatting事件,在事件中取出图片路径,读取图片赋值给当前单元格. private void dataGridview1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (dataGridview1.Columns[e.ColumnIndex].Name.Equals("Image")) { string path = e.Valu
-
WinForm生成验证码图片的方法
本文实例讲述了WinForm生成验证码图片的方法.分享给大家供大家参考,具体如下: 1.创建ValidCode类: public class ValidCode { #region Private Fields private const double PI = 3.1415926535897932384626433832795; private const double PI2 = 6.283185307179586476925286766559; //private readonly int
-
WinForm中实现picturebox自适应图片大小的方法
本文实例讲述了WinForm中实现picturebox自适应图片大小的方法.分享给大家供大家参考,具体如下: picturebox控件共有两种载入图片方式,分别为: pictureBox1.BackgroundImage = Image,pictureBox1.load(url) 为使加载的图片自使用控件尺寸,可以分别对pictureBox控件设置BackGroundImageLayout=Stretch,SizeMode=StretchImagewinform中picturebox自适应图片大
-
WinForm实现的图片拖拽与缩放功能示例
本文实例讲述了WinForm实现的图片拖拽与缩放功能.分享给大家供大家参考,具体如下: 最近做项目的时候遇到上传施工平面布置图,查看,因为图片比较大,一般的显示器分辨率无法显示全,然后还需要放大看清楚图片里面的文字内容,所以需要用到图片的拖拽与缩放功能.这里整理下具体操作. 首先新建一个窗体,拖一个panel控件到窗体中,然后在拖一个pictureobx控件到panel中,然后在添加个上传图片的按钮: 具体代码: using System; using System.Collections.Ge
-
winform 中显示异步下载的图片
private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { ////利用 WebClient 来下载图片 using (WebClient wc = new WebClient()) { ////WebClient 下载完毕的响应事件绑定 wc.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wc_Dow
-
Winform实现将网页生成图片的方法
通常浏览器都有将网页生成图片的功能,本文实例讲述了Winform实现将网页生成图片的方法.分享给大家供大家参考.具体方法如下: 工具截图如下: 生成后的图片如下: 手动填写网站地址,可选择图片类型和保持图片地址,来生成页面的图片,当图片路径未选择时则保存桌面: 具体代码如下: 将html生成图片的类 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usi
随机推荐
- Golang实现字符串倒序的几种解决方案
- perl中使用ip138网站查询ip归属地脚本分享
- PowerShell实现在控制台中插入绿色的打勾符号
- Access数据库提示OleDbException (0x80004005): 操作必须使用一个可更新的查询
- AngularJS实现的JSONP跨域访问数据传输功能详解
- Windows Server 2012 R2或2016无法安装.NET Framework 3.5.1的解决方法
- 详解Swift语言中的类与结构体
- 几种显示数据的方法的比较
- JavaScipt中的Math.ceil() 、Math.floor() 、Math.round() 三个函数的理解
- 利用Nginx反向代理功能解决WEB网站80端口被封的解决方法
- Email地址加密javascript版
- c++实现发送http请求通过get方式获取网页源代码
- angularjs实现对表单输入改变的监控(ng-change和watch两种方式)
- 了解javascript中变量及函数的提升
- mysql 5.7.17 以及workbench安装配置图文教程
- Python日志无延迟实时写入的示例
- 浅谈python 中类属性共享的问题
- 使用python模拟命令行终端的示例
- vue采用EventBus实现跨组件通信及注意事项小结
- javascript、php关键字搜索函数的使用方法