ToolStripItem.AllowDrop 속성

정의

사용자가 구현한 이벤트를 통해 끌어서 놓기 및 항목 다시 정렬을 처리할지 여부를 나타내는 값 가져오거나 설정합니다.

public:
 virtual property bool AllowDrop { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public virtual bool AllowDrop { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.AllowDrop : bool with get, set
Public Overridable Property AllowDrop As Boolean

속성 값

컨트롤에서 끌어서 놓기 작업을 수행할 수 있으면 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

특성

예외

AllowDropAllowItemReorder가 둘 다 true로 설정된 경우

예제

다음 코드 예제를 설정 하는 방법을 보여 줍니다는 AllowDrop 속성입니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ToolStripItem 클래스입니다.

// 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 설정하고 속성을 로 설정 AllowItemReorderfalse 하여 , ToolStripItem.DragLeaveToolStripItem.DragDrop 이벤트에서 정의한 끌어서 놓기 동작에 ToolStripItem.DragEnter응답합니다.

속성을 로 AllowDropfalse 설정하고 속성을 true 로 설정 AllowItemReorder 하여 클래스가 ToolStripItem 끌어서 놓기 및 항목 다시 정렬을 비공개로 처리하도록 합니다.

AllowItemReorder 속성을 둘 다 AllowDrop 설정하면 true 예외가 throw됩니다.

적용 대상