Winform讓DataGridView左側(cè)顯示圖片
更新時間:2016年05月30日 12:04:26 作者:秦風(fēng)
本文主要介紹在如何讓DataGridView左側(cè)顯示圖片,這里主要講解重寫DataGridView的OnRowPostPaint方法,需要的朋友可以參考下。
效果圖片
重寫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#開發(fā)WinForm根據(jù)條件改變DataGridView行顏色
- WinForm使用DataGridView實現(xiàn)類似Excel表格的查找替換功能
- C#開發(fā)WinForm之DataGridView開發(fā)詳解
- Winform在DataGridView中顯示圖片
- WinForm中DataGridView折疊控件【超好看】
- winform用datagridview制作課程表實例
- WinForm中DataGridView添加,刪除,修改操作具體方法
- WinForm DataGridView控件隔行變色的小例子
- C#開發(fā)WinForm清空DataGridView控件綁定的數(shù)據(jù)
相關(guān)文章
c# winform讀取xml文件創(chuàng)建菜單的代碼
動態(tài)創(chuàng)建菜單使得程序靈活性大大增加,本文根據(jù)讀取xml文件中的配置菜單項來動態(tài)創(chuàng)建菜單,代碼如下2013-09-09Extjs4如何處理后臺json數(shù)據(jù)中日期和時間
本文給大家分享Extjs4如何處理后臺json數(shù)據(jù)中日期和時間,通過代碼示例給大家剖析,感興趣的朋友快來圍觀2015-08-08C#實現(xiàn)win10 uwp 右擊浮出窗在點擊位置
本文主要讓MenuFlyout出現(xiàn)在我們右擊位置。我們建一個ListView,然后綁定后臺,在我們ListView要右擊顯示我們的浮出,要求我們的浮出在我們點擊位置2016-10-10Unity學(xué)習(xí)之FSM有限狀態(tài)機
這篇文章主要介紹了Unity學(xué)習(xí)之FSM有限狀態(tài)機,通過詳細(xì)的代碼案例來進行解析說明,希望這篇文章對你有所幫助2021-06-06