DrawListViewItemEventArgs.DrawDefault プロパティ

定義

ListView コントロールで ListViewItem に既定の描画が使用されるかどうかを示すプロパティを取得または設定します。

public:
 property bool DrawDefault { bool get(); void set(bool value); };
public bool DrawDefault { get; set; }
member this.DrawDefault : bool with get, set
Public Property DrawDefault As Boolean

プロパティ値

システムによって項目が描画される場合は true。イベント ハンドラーによって項目が描画される場合は false。 既定値は false です。

次のコード例では、このメンバーの使用方法を示します。 この例では、イベント ハンドラーがイベントの ListView.DrawItem 発生を報告します。 このレポートは、イベントが発生したタイミングを知るのに役立ち、デバッグに役立ちます。

コード例を実行するには、 という名前ListView1の型ListViewのインスタンスを含むプロジェクトに貼り付けます。 次に、イベント ハンドラーが イベントに関連付けられていることを確認します ListView.DrawItem

private void ListView1_DrawItem(Object sender, DrawListViewItemEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "DrawDefault", e.DrawDefault );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Graphics", e.Graphics );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Item", e.Item );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Bounds", e.Bounds );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ItemIndex", e.ItemIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "State", e.State );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "DrawItem Event" );
}
Private Sub ListView1_DrawItem(sender as Object, e as DrawListViewItemEventArgs) _ 
     Handles ListView1.DrawItem

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "DrawDefault", e.DrawDefault)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Graphics", e.Graphics)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Item", e.Item)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Bounds", e.Bounds)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ItemIndex", e.ItemIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "State", e.State)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"DrawItem Event")

End Sub

注釈

アイテムにカスタム描画が必要ない場合は、このプロパティを に true 設定します。 これは、選択した項目など、コントロール内の特定の項目のみをカスタマイズする必要がある場合に便利です。

適用対象