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.

C#
[System.ComponentModel.Browsable(false)]
public virtual bool AllowDrop { get; set; }

Valor de propiedad

true si están permitidas las operaciones de arrastrar y colocar en el control; en caso contrario, false. De manera predeterminada, es false.

Atributos

Excepciones

Tanto AllowDrop como AllowItemReorder se establecen en true.

Ejemplos

En el ejemplo de código siguiente se muestra cómo establecer la AllowDrop propiedad . Este ejemplo de código es parte de un ejemplo más grande proporcionado para la clase ToolStripItem.

C#
// 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;
}

Comentarios

Establezca la AllowDrop propiedad true en 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 .

Establezca la AllowDrop propiedad false en y establezca la AllowItemReorder propiedad en true para que la clase controle la ToolStripItem operación de arrastrar y colocar y el reordenamiento de elementos de forma privada.

Al establecer las AllowDrop propiedades y AllowItemReorder para true que se produzca una excepción.

Se aplica a

Producto Versiones
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10