我也是特别的想知道,因为listView里面没有对背景绘画的事件。在CSDN文档区里好像有一篇文章讲了对treeView进行画背景,是VB.Net的。关注这个问题

解决方案 »

  1.   

    namespace Packing.NET
    {
    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 是不支持透明的背景颜色的!正在寻求解决方法......
      

  2.   

    等待解决的更好办法;
    如果能够像金山词霸的当然更好(TreeView也可以)。