ListViewInsertionMark.Color プロパティ

定義

挿入マークの色を取得または設定します。Gets or sets the color of the insertion mark.

public:
 property System::Drawing::Color Color { System::Drawing::Color get(); void set(System::Drawing::Color value); };
public System.Drawing.Color Color { get; set; }
member this.Color : System.Drawing.Color with get, set
Public Property Color As Color

プロパティ値

挿入マークの色を表す Color 値。A Color value that represents the color of the insertion mark. 既定値は ForeColor プロパティの値です。The default value is the value of the ForeColor property.

次のコード例は、 ListView挿入マーク機能を使用し、標準のドラッグイベントを使用してドラッグアンドドロップ項目の並べ替えを実装する方法を示しています。The following code example demonstrates how to use the ListView insertion mark feature and implements drag-and-drop item reordering using the standard drag events. 挿入マークの位置は、 Control.DragOverイベントのハンドラーで更新されます。The position of the insertion mark is updated in a handler for the Control.DragOver event. このハンドラーでは、マウスポインターの位置は最も近い項目の中間点と比較され、結果は、挿入マークが項目の左側または右側に表示されるかどうかを判断するために使用されます。In this handler, the position of the mouse pointer is compared to the midpoint of the nearest item, and the result is used to determine whether the insertion mark appears to the left or the right of the item.

完全な例についてはListViewInsertionMark 、「概要リファレンス」トピックを参照してください。For the complete example, see the ListViewInsertionMark overview reference topic.

   ListViewInsertionMarkExample()
   {
      // Initialize myListView.
      myListView = gcnew ListView;
      myListView->Dock = DockStyle::Fill;
      myListView->View = View::LargeIcon;
      myListView->MultiSelect = false;
      myListView->ListViewItemSorter = gcnew ListViewIndexComparer;

      // Initialize the insertion mark.
      myListView->InsertionMark->Color = Color::Green;

      // Add items to myListView.
      myListView->Items->Add( "zero" );
      myListView->Items->Add( "one" );
      myListView->Items->Add( "two" );
      myListView->Items->Add( "three" );
      myListView->Items->Add( "four" );
      myListView->Items->Add( "five" );

      // Initialize the drag-and-drop operation when running
      // under Windows XP or a later operating system.
      if ( System::Environment::OSVersion->Version->Major > 5 || (System::Environment::OSVersion->Version->Major == 5 && System::Environment::OSVersion->Version->Minor >= 1) )
      {
         myListView->AllowDrop = true;
         myListView->ItemDrag += gcnew ItemDragEventHandler( this, &ListViewInsertionMarkExample::myListView_ItemDrag );
         myListView->DragEnter += gcnew DragEventHandler( this, &ListViewInsertionMarkExample::myListView_DragEnter );
         myListView->DragOver += gcnew DragEventHandler( this, &ListViewInsertionMarkExample::myListView_DragOver );
         myListView->DragLeave += gcnew EventHandler( this, &ListViewInsertionMarkExample::myListView_DragLeave );
         myListView->DragDrop += gcnew DragEventHandler( this, &ListViewInsertionMarkExample::myListView_DragDrop );
      }

      // Initialize the form.
      this->Text = "ListView Insertion Mark Example";
      this->Controls->Add( myListView );
   }

private:

public ListViewInsertionMarkExample()
{
    // Initialize myListView.
    myListView = new ListView();
    myListView.Dock = DockStyle.Fill;
    myListView.View = View.LargeIcon;
    myListView.MultiSelect = false;
    myListView.ListViewItemSorter = new ListViewIndexComparer();

    // Initialize the insertion mark.
    myListView.InsertionMark.Color = Color.Green;

    // Add items to myListView.
    myListView.Items.Add("zero");
    myListView.Items.Add("one");
    myListView.Items.Add("two");
    myListView.Items.Add("three");
    myListView.Items.Add("four");
    myListView.Items.Add("five");
    
    // Initialize the drag-and-drop operation when running
    // under Windows XP or a later operating system.
    if (OSFeature.Feature.IsPresent(OSFeature.Themes))
    {
        myListView.AllowDrop = true;
        myListView.ItemDrag += new ItemDragEventHandler(myListView_ItemDrag);
        myListView.DragEnter += new DragEventHandler(myListView_DragEnter);
        myListView.DragOver += new DragEventHandler(myListView_DragOver);
        myListView.DragLeave += new EventHandler(myListView_DragLeave);
        myListView.DragDrop += new DragEventHandler(myListView_DragDrop);
    }

    // Initialize the form.
    this.Text = "ListView Insertion Mark Example";
    this.Controls.Add(myListView);
}
Public Sub New()
    ' Initialize myListView.
    myListView = New ListView()
    myListView.Dock = DockStyle.Fill
    myListView.View = View.LargeIcon
    myListView.MultiSelect = False
    myListView.ListViewItemSorter = New ListViewIndexComparer()
    
    ' Initialize the insertion mark.
    myListView.InsertionMark.Color = Color.Green
    
    ' Add items to myListView.
    myListView.Items.Add("zero")
    myListView.Items.Add("one")
    myListView.Items.Add("two")
    myListView.Items.Add("three")
    myListView.Items.Add("four")
    myListView.Items.Add("five")
    
    ' Initialize the drag-and-drop operation when running
    ' under Windows XP or a later operating system.
    If OSFeature.Feature.IsPresent(OSFeature.Themes)
        myListView.AllowDrop = True
        AddHandler myListView.ItemDrag, AddressOf myListView_ItemDrag
        AddHandler myListView.DragEnter, AddressOf myListView_DragEnter
        AddHandler myListView.DragOver, AddressOf myListView_DragOver
        AddHandler myListView.DragLeave, AddressOf myListView_DragLeave
        AddHandler myListView.DragDrop, AddressOf myListView_DragDrop
    End If 

    ' Initialize the form.
    Me.Text = "ListView Insertion Mark Example"
    Me.Controls.Add(myListView)
End Sub

注釈

このプロパティを使用して、挿入マークの色をListViewコントロールの前景色以外の値に設定します。Use this property to set the insertion mark color to a value other than the foreground color of the ListView control.

適用対象

こちらもご覧ください