ToolStripItem.AllowDrop プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ToolStripItem.AllowDrop プロパティの意味・解説 

ToolStripItem.AllowDrop プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

実装するイベントによって、ドラッグ アンド ドロップおよび項目の順番変更が処理されるかどうかを示す値を取得または設定します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Overridable Property
 AllowDrop As Boolean
Dim instance As ToolStripItem
Dim value As Boolean

value = instance.AllowDrop

instance.AllowDrop = value
public virtual bool AllowDrop { get;
 set; }
/** @property */
public boolean get_AllowDrop ()

/** @property */
public void set_AllowDrop (boolean value)

プロパティ値
コントロールでドラッグ アンド ドロップ操作を実行できる場合は true。それ以外の場合は false。既定値は false です。

例外例外
例外の種類条件

ArgumentException

AllowDrop および AllowItemReorder がどちらも true に設定されています。

解説解説

ToolStripItem.DragEnter、ToolStripItem.DragLeave、および ToolStripItem.DragDrop の各イベントで定義したドラッグ アンド ドロップ動作に応答するには、AllowDrop プロパティを true に設定して、AllowItemReorder プロパティを false に設定します。

ToolStripItem クラスによってドラッグ アンド ドロップおよび項目の順番変更をプライベートで処理するには、AllowDrop プロパティを false に設定して、AllowItemReorder プロパティを true に設定します。

AllowDrop プロパティと AllowItemReorder プロパティの両方を true に設定すると、例外がスローされます。

使用例使用例

AllowDrop プロパティを設定する方法を次のコード例に示します。このコード例は、ToolStripItem クラスのトピックで取り上げているコード例の一部分です。

' 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
// 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;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

ToolStripItem.AllowDrop プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ToolStripItem.AllowDrop プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS