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。
例
次のコード例では、コントロールのカスタム描画を Item 提供するアプリケーションで プロパティを使用する方法を ListView 示します。 この例では、 イベントのハンドラーによって 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 必要があります。