In Depth Banner
Skip Navigation Links

Select your preferred language

Delegates and event arguments

  public delegate void ItemPaintEventHandler(object sender, ListViewItemPaintEventArgs e);

  /// <summary>

  /// Provides information about the current item being drawn

  /// </summary>

  public class ListViewItemPaintEventArgs : EventArgs

  {

 

    /// <summary>

    /// Constructs a new ListViewItemPaintEventArgs object. 

    /// </summary>

    /// <param name="gr">The graphics object provided by the ListView.  </param>

    /// <param name="i">The item being drawn.  </param>

    /// <param name="rc">The rectangle into which the item should be drawn.  </param>

    /// <param name="subItem">The sub item currently being drawn.  </param>

    /// <param name="issub">True when this object pertains to a sub item.  </param>

    /// <param name="vw">The current view style.  </param>

    /// <param name="itemOffset">An integer offset that specifies how far the main item text to be offset from the left side, the rectangle.  This changes depending upon whether the item is displayed with an icon or a check box.  </param>

    public ListViewItemPaintEventArgs(Graphics gr, ListViewItem i, Rectangle rc, int subItem, bool issub, View vw, int itemOffset)

    {

      _graphics=gr;

      _item=i;

      _itemRect=rc;

      _subItemIndex=subItem;

      _isSubItem=issub;

      _view=vw;

      _itemOffset=itemOffset;

    }

 

    /// <summary>

    /// Protected default constructor. 

    /// </summary>

    /// <remarks>This object can only be created using the correct parameters.  </remarks>

    protected ListViewItemPaintEventArgs()

    {

    }

 

    int _itemOffset;

    /// <summary>

    /// Gets and sets the offset at which the first item text should be drawn. 

    /// </summary>

    public int ItemOffset

    {

      get{return _itemOffset;}

      set{_itemOffset=value;}

    }

 

 

    Graphics _graphics;

    /// <summary>

    /// Gets the graphic object provided by the list view. 

    /// </summary>

    public Graphics Graphics

    {

      get{return _graphics;}

    }

    

    Rectangle _itemRect;

    /// <summary>

    /// Gets the rectangle into which the item should be drawn. 

    /// </summary>

    public Rectangle ItemRect

    {

      get{return _itemRect;}

    }

 

    ListViewItem _item;

    /// <summary>

    /// Gets the item currently being drawn. 

    /// </summary>

    public ListViewItem Item

    {

      get{return _item;}

    }

 

    int _subItemIndex;

    /// <summary>

    /// Gets the sub item index being drawn.  

    /// </summary>

    /// <remarks>If this is zero it is the main item being drawn.  </remarks>

    public int SubItemIndex

    {

      get{return _subItemIndex;}

    }

 

    bool _isSubItem;

    /// <summary>

    /// When true, a sub item is being drawn. 

    /// </summary>

    public bool IsSubItem

    {

      get{return _isSubItem;}

    }

 

 

    bool _drawSubItems;

    /// <summary>

    /// Gets and sets a flag that enables the drawings of sub items. 

    /// </summary>

    /// <remarks>When drawing in detail view mode, you have the opportunity to either draw the complete item or request notification of each sub item as it is drawn. 

    /// if you require some item drawing, set this member to true whenever <see cref="IsSubItem"/> is false. 

    /// In this case, do not do any drawing.  </remarks>

    public bool DrawSubItems

    {

      get{return _drawSubItems;}

      set{_drawSubItems=value;}

    }

 

    View _view;

    /// <summary>

    /// Gets the current view setting

    /// </summary>

    public View View

    {

      get{return _view;}

    }

 

    bool _doDefault;

    /// <summary>

    /// Gets and sets a value that specifies that the list view should to the default drawing. 

    /// </summary>

    /// <remarks>During any item drawing stage, you may set this member to true to signify that you expect the list view to perform the standard drawing.  </remarks>

    public bool DoDefault

    {

      get{return _doDefault;}

      set{_doDefault=value;}

    }

 

 

  }

 

  public delegate void QueryCustomDrawHandler(object sender, QueryCustomDrawEventArgs e);

 

  /// <summary>

  /// Event and arguments that enable you to decide whether custom drawing will take place or not. 

  /// </summary>

  public class QueryCustomDrawEventArgs : EventArgs

  {

    /// <summary>

    /// Constructs a new QueryCustomDrawEventArgs object with the view parameter. 

    /// </summary>

    /// <param name="vw">The current view style.  </param>

    public QueryCustomDrawEventArgs(View vw)

    {

      _view=vw;

    }

 

    View _view;

    /// <summary>

    /// Gets the view style provided by the list you. 

    /// </summary>

    /// <remarks>

    /// Use this to decide whether you want to perform custom drawing in this particular view style. 

    /// </remarks>

    public View View

    {

      get{return _view;}

    }

 

    bool _Inform;

    /// <summary>

    /// Gets and sets a value that enables you to obtain further notifications from the list view object. 

    /// </summary>

    /// <remarks>

    /// When you receive these events arguments you should send this member to true if you wish to form custom drawing. 

    /// Setting this member to false will prevent any further custom drawn notifications in this paint cycle. 

    /// </remarks>

    public bool Inform

    {

      get{return _Inform;}

      set{_Inform=value;}

    }

 

    bool _subitems;

    /// <summary>

    /// When the view mode is set to detail view you can set this member to true to signify

    /// that a notification should be sent for each sub item.

    /// </summary>

    public bool Subitems

    {

      get{return _subitems;}

      set{_subitems=value;}

    }

  }

 

Return to the article.

Copyright © Bob Powell 2003-2009. All rights reserved