我也是特别的想知道,因为listView里面没有对背景绘画的事件。在CSDN文档区里好像有一篇文章讲了对treeView进行画背景,是VB.Net的。关注这个问题
解决方案 »
- C#中录音采样点的音量属性
- 想加第三个表,作为子表的子表,应该加什么语句?
- 关于正则表达式
- 如何将后插入的数据显示在前面?
- 本地化的问题,求教高手
- 请问既然Ilist已经继承了ICollection,为何CollectionBase类仍然要同时继承这2个接口?
- SqlCommandBuilder不能自动生成其它sql
- 由于目标机器积极拒绝,无法连接127.0.0.1:8888
- 简明扼要,,,,,,问个窗口设计的小白问题,,求教。。
- 各位大哥,麻烦看看下面这段代码,在ie6下一点问题都没有,但是在Ie7下却显示不出效果,经查是Response.WriteFile(filePath)的问题,估计是iE7安全性太高,可是设为最低还不行,大家帮解决下啊.
- 类型构造器和实例构造器
- 串口通信
{
public class ListViewEx : System.Windows.Forms.ListView
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private const int WM_PAINT = 0x000F;
private const int WM_ERASEBKGND = 0x0014; /// <summary>
/// 背景图像
/// </summary>
[Description("背景图像")]
[Browsable(true)]
public override Image BackgroundImage
{
get
{
return base.BackgroundImage;
}
set
{
base.BackgroundImage = value;
}
} public ListViewEx()
{
InitializeComponent();
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} protected override void WndProc( ref Message m )
{
base.WndProc(ref m); switch( m.Msg )
{
case WM_ERASEBKGND:
if ( BackgroundImage != null )
{
Graphics g = Graphics.FromHdc( (IntPtr) m.WParam );
g.DrawImage( BackgroundImage, this.ClientRectangle );
} break;
}
} #region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
Application.EnableVisualStyles();
components = new System.ComponentModel.Container();
}
#endregion
}
}
背景图是画出来了,但是每个 ListViewItem 的背景颜色都是白色,因为 ListView 是不支持透明的背景颜色的!正在寻求解决方法......
如果能够像金山词霸的当然更好(TreeView也可以)。