Winform讓DataGridView左側(cè)顯示圖片
效果圖片
重寫(xiě)DataGridView的OnRowPostPaint方法或者直接在DataGridView的RowPostPaint事件里寫(xiě),如下(重寫(xiě)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對(duì)象, e.RowBounds.Location.X, e.RowBounds.Location.Y); base.OnRowPostPaint(e); } } }
以上就是重寫(xiě)DataGridView的OnRowPostPaint方法,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- C#開(kāi)發(fā)WinForm根據(jù)條件改變DataGridView行顏色
- WinForm使用DataGridView實(shí)現(xiàn)類似Excel表格的查找替換功能
- C#開(kāi)發(fā)WinForm之DataGridView開(kāi)發(fā)詳解
- Winform在DataGridView中顯示圖片
- WinForm中DataGridView折疊控件【超好看】
- winform用datagridview制作課程表實(shí)例
- WinForm中DataGridView添加,刪除,修改操作具體方法
- WinForm DataGridView控件隔行變色的小例子
- C#開(kāi)發(fā)WinForm清空DataGridView控件綁定的數(shù)據(jù)
相關(guān)文章
c# winform讀取xml文件創(chuàng)建菜單的代碼
動(dòng)態(tài)創(chuàng)建菜單使得程序靈活性大大增加,本文根據(jù)讀取xml文件中的配置菜單項(xiàng)來(lái)動(dòng)態(tài)創(chuàng)建菜單,代碼如下2013-09-09Extjs4如何處理后臺(tái)json數(shù)據(jù)中日期和時(shí)間
本文給大家分享Extjs4如何處理后臺(tái)json數(shù)據(jù)中日期和時(shí)間,通過(guò)代碼示例給大家剖析,感興趣的朋友快來(lái)圍觀2015-08-08C#實(shí)現(xiàn)win10 uwp 右擊浮出窗在點(diǎn)擊位置
本文主要讓MenuFlyout出現(xiàn)在我們右擊位置。我們建一個(gè)ListView,然后綁定后臺(tái),在我們ListView要右擊顯示我們的浮出,要求我們的浮出在我們點(diǎn)擊位置2016-10-10C#觀察者模式(Observer Pattern)實(shí)例教程
這篇文章主要介紹了C#觀察者模式(Observer Pattern),主要以一個(gè)實(shí)例的形式講述了C#觀察者模式的實(shí)現(xiàn)過(guò)程,詳細(xì)講述了接口的定義、通知及動(dòng)作的實(shí)現(xiàn)方法,需要的朋友可以參考下2014-09-09Unity學(xué)習(xí)之FSM有限狀態(tài)機(jī)
這篇文章主要介紹了Unity學(xué)習(xí)之FSM有限狀態(tài)機(jī),通過(guò)詳細(xì)的代碼案例來(lái)進(jìn)行解析說(shuō)明,希望這篇文章對(duì)你有所幫助2021-06-06