ToolStripItem.AllowDrop Propiedad

Definición

Obtiene o establece un valor que indica si las operaciones de arrastrar y colocar y la reordenación de elementos se controlan mediante eventos que se implementan.Gets or sets a value indicating whether drag-and-drop and item reordering are handled through events that you implement.

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

Valor de propiedad

true si están permitidas las operaciones de arrastrar y colocar en el control; en caso contrario, false.true if drag-and-drop operations are allowed in the control; otherwise, false. De manera predeterminada, es false.The default is false.

Atributos

Excepciones

Tanto AllowDrop como AllowItemReorder se establecen en true.AllowDrop and AllowItemReorder are both set to true.

Ejemplos

En el ejemplo de código siguiente se muestra cómo AllowDrop establecer la propiedad.The following code example demonstrates how to set the AllowDrop property. Este ejemplo de código forma parte de un ejemplo más extenso proporcionado ToolStripItem para la clase.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

Comentarios

Establezca la AllowDrop propiedad en true y establezca la AllowItemReorder propiedad en false para responder al comportamiento de arrastrar y colocar que ha definido en los ToolStripItem.DragEntereventos, ToolStripItem.DragLeavey 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.

Establezca la AllowDrop propiedad en false y establezca la AllowItemReorder propiedad en true para que la ToolStripItem clase controle la función de arrastrar y colocar y la reordenación de elementos de forma privada.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.

Al establecer las AllowItemReorder propiedades true y en se produce una excepción. AllowDropSetting both the AllowDrop and the AllowItemReorder properties to true throws an exception.

Se aplica a