ToolStripItem.AllowDrop 속성


사용자가 구현한 이벤트를 통해 끌어서 놓기 및 항목 다시 정렬을 처리할지 여부를 나타내는 값 가져오거나 설정합니다.Gets or sets a value indicating whether drag-and-drop and item reordering are handled through events that you implement.

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

속성 값

컨트롤에서 끌어서 놓기 작업을 수행할 수 있으면 true이고, 그렇지 않으면 false입니다.true if drag-and-drop operations are allowed in the control; otherwise, false. 기본값은 false입니다.The default is false.



AllowDropAllowItemReorder가 둘 다 true로 설정된 경우AllowDrop and AllowItemReorder are both set to true.


다음 코드 예제에서는 설정 하는 방법에 설명 합니다 AllowDrop 속성입니다.The following code example demonstrates how to set the AllowDrop property. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ToolStripItem 클래스입니다.This code example is part of a larger example provided for the ToolStripItem class.

// This utility method creates a RolloverItem 
// and adds it to a ToolStrip control.
private RolloverItem CreateRolloverItem(
    ToolStrip owningToolStrip,
    string txt,
    Font f,
    string imgKey,
    TextImageRelation tir,
    string backImgKey)
    RolloverItem item = new RolloverItem();

    item.Alignment = ToolStripItemAlignment.Left;
    item.AllowDrop = false;
    item.AutoSize = true;

    item.BackgroundImage = owningToolStrip.ImageList.Images[backImgKey];
    item.BackgroundImageLayout = ImageLayout.Center;
    item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
    item.DoubleClickEnabled = true;
    item.Enabled = true;
    item.Font = f;

    // These assignments are equivalent. Each assigns an
    // image from the owning toolstrip's image list.
    item.ImageKey = imgKey;
    //item.Image = owningToolStrip.ImageList.Images[infoIconKey];
    //item.ImageIndex = owningToolStrip.ImageList.Images.IndexOfKey(infoIconKey);
    item.ImageScaling = ToolStripItemImageScaling.None;

    item.Owner = owningToolStrip;
    item.Padding = new Padding(2);
    item.Text = txt;
    item.TextAlign = ContentAlignment.MiddleLeft;
    item.TextDirection = ToolStripTextDirection.Horizontal;
    item.TextImageRelation = tir;

    return item;
' This utility method creates a RolloverItem 
' and adds it to a ToolStrip control.
 Private Function CreateRolloverItem( _
 ByVal owningToolStrip As ToolStrip, _
 ByVal txt As String, _
 ByVal f As Font, _
 ByVal imgKey As String, _
 ByVal tir As TextImageRelation, _
 ByVal backImgKey As String) As RolloverItem

     Dim item As New RolloverItem()

     item.Alignment = ToolStripItemAlignment.Left
     item.AllowDrop = False
     item.AutoSize = True

     item.BackgroundImage = owningToolStrip.ImageList.Images(backImgKey)
     item.BackgroundImageLayout = ImageLayout.Center
     item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
     item.DoubleClickEnabled = True
     item.Enabled = True
     item.Font = f

     ' These assignments are equivalent. Each assigns an
     ' image from the owning toolstrip's image list.
     item.ImageKey = imgKey
     'item.Image = owningToolStrip.ImageList.Images[infoIconKey];
     'item.ImageIndex = owningToolStrip.ImageList.Images.IndexOfKey(infoIconKey);
     item.ImageScaling = ToolStripItemImageScaling.None

     item.Owner = owningToolStrip
     item.Padding = New Padding(2)
     item.Text = txt
     item.TextAlign = ContentAlignment.MiddleLeft
     item.TextDirection = ToolStripTextDirection.Horizontal
     item.TextImageRelation = tir

     Return item
 End Function


설정 합니다 AllowDrop 속성을 true 설정는 AllowItemReorder 속성을 false 에서 정의한 끌어서 놓기 동작에 응답 하는 ToolStripItem.DragEnter, ToolStripItem.DragLeave, 및 ToolStripItem.DragDrop 이벤트.Set the AllowDrop property to true and set the AllowItemReorder property to false to respond to drag-and-drop behavior you have defined in the ToolStripItem.DragEnter, ToolStripItem.DragLeave, and ToolStripItem.DragDrop events.

설정 합니다 AllowDrop 속성을 false 설정 합니다 AllowItemReorder 속성을 true 시킬는 ToolStripItem 끌어서 놓기 및 개인적으로 다시 정렬 하는 항목을 처리 하는 클래스.Set the AllowDrop property to false and set the AllowItemReorder property to true to cause the ToolStripItem class to handle drag-and-drop and item reordering privately.

모두 설정 합니다 AllowDrop 하며 AllowItemReorder 속성을 true 예외를 throw 합니다.Setting both the AllowDrop and the AllowItemReorder properties to true throws an exception.

적용 대상