DrawListViewItemEventArgs.Item 属性      
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取要绘制的 ListViewItem。
public:
 property System::Windows::Forms::ListViewItem ^ Item { System::Windows::Forms::ListViewItem ^ get(); };
	public System.Windows.Forms.ListViewItem Item { get; }
	member this.Item : System.Windows.Forms.ListViewItem
	Public ReadOnly Property Item As ListViewItem
	属性值
要绘制的 ListViewItem。
示例
下面的代码示例演示如何在为控件提供自定义绘图ListView的应用程序中使用 Item 属性。 在此示例中,事件的处理程序 ListView.DrawItem 绘制整个项的背景。 在除详细信息视图以外的所有视图中,此处理程序还会绘制前景文本。 在详细信息视图中,将在 事件中 ListView.DrawSubItem 绘制前景文本。
有关完整示例,请参阅 DrawListViewItemEventArgs 概述参考主题。
// Draws the backgrounds for entire ListView items.
private void listView1_DrawItem(object sender,
    DrawListViewItemEventArgs e)
{
    if ((e.State & ListViewItemStates.Selected) != 0)
    {
        // Draw the background and focus rectangle for a selected item.
        e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds);
        e.DrawFocusRectangle();
    }
    else
    {
        // Draw the background for an unselected item.
        using (LinearGradientBrush brush =
            new LinearGradientBrush(e.Bounds, Color.Orange,
            Color.Maroon, LinearGradientMode.Horizontal))
        {
            e.Graphics.FillRectangle(brush, e.Bounds);
        }
    }
    // Draw the item text for views other than the Details view.
    if (listView1.View != View.Details)
    {
        e.DrawText();
    }
}
' Draws the backgrounds for entire ListView items.
Private Sub listView1_DrawItem(ByVal sender As Object, _
    ByVal e As DrawListViewItemEventArgs) _
    Handles listView1.DrawItem
    If Not (e.State And ListViewItemStates.Selected) = 0 Then
        ' Draw the background for a selected item.
        e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds)
        e.DrawFocusRectangle()
    Else
        ' Draw the background for an unselected item.
        Dim brush As New LinearGradientBrush(e.Bounds, Color.Orange, _
            Color.Maroon, LinearGradientMode.Horizontal)
        Try
            e.Graphics.FillRectangle(brush, e.Bounds)
        Finally
            brush.Dispose()
        End Try
    End If
    ' Draw the item text for views other than the Details view.
    If Not Me.listView1.View = View.Details Then
        e.DrawText()
    End If
End Sub
	注解
使用此属性访问 ListViewItem 以绘制。 当 属性未提供足够的信息来满足你的需求时 State ,这非常有用。 属性 State 仅提供可以使用的基本状态信息,例如,用于确定是选择、选中还是聚焦项。 另一方面, 属性 Item 允许访问 的所有成员 ListViewItem。 例如,必须直接访问项才能自行绘制值, ListViewItem.Text 而不是使用 DrawText 方法。