ToolStripItemPlacementとは? わかりやすく解説

ToolStripItem.Placement プロパティ

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

項目の現在のレイアウト取得します

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

Public ReadOnly Property
 Placement As ToolStripItemPlacement
Dim instance As ToolStripItem
Dim value As ToolStripItemPlacement

value = instance.Placement
public ToolStripItemPlacement Placement { get;
 }
public:
property ToolStripItemPlacement Placement {
    ToolStripItemPlacement get ();
}
/** @property */
public ToolStripItemPlacement get_Placement ()
public function get Placement
 () : ToolStripItemPlacement

プロパティ
ToolStripItemPlacement 値の 1 つ

使用例使用例

Placement プロパティ使ったカスタム レンダリング方法を、次のコード例示します。このコード例は、ToolStripItem クラストピック取り上げているコード例一部分です。

' This method defines the behavior for rendering the
' background of a ToolStripItem. If the item is a
' RolloverItem, it paints the item's BackgroundImage 
' centered in the client area. If the mouse is in the 
' item's client area, a border is drawn around it.
' If the item is on a drop-down or if it is on the
' overflow, a gradient is painted in the background.
Protected Overrides Sub
 OnRenderItemBackground(ByVal e As ToolStripItemRenderEventArgs)
    MyBase.OnRenderItemBackground(e)

    Dim item As RolloverItem = e.Item 

    ' If the ToolSTripItem is of type RolloverItem, 
    ' perform custom rendering for the background.
    If Not (item Is Nothing)
 Then
        If item.Placement = ToolStripItemPlacement.Overflow OrElse
 item.IsOnDropDown Then
            Dim b As New
 LinearGradientBrush(item.ContentRectangle, Color.Salmon, Color.DarkRed, 0.0F, False)
            Try
                e.Graphics.FillRectangle(b, item.ContentRectangle)
            Finally
                b.Dispose()
            End Try
        End If

        ' The RolloverItem control only supports 
        ' the ImageLayout.Center setting for the
        ' BackgroundImage property.
        If item.BackgroundImageLayout = ImageLayout.Center Then
            ' Get references to the item's ContentRectangle
            ' and BackgroundImage, for convenience.
            Dim cr As Rectangle = item.ContentRectangle
            Dim bgi As Image = item.BackgroundImage

            ' Compute the center of the item's ContentRectangle.
            Dim centerX As Integer
 = (cr.Width - bgi.Width) / 2
            Dim centerY As Integer
 = (cr.Height - bgi.Height) / 2

            ' If the item is selected, draw the background
            ' image as usual. Otherwise, draw it as disabled.
            If item.Selected Then
                e.Graphics.DrawImage(bgi, centerX, centerY)
            Else
                ControlPaint.DrawImageDisabled(e.Graphics, bgi, centerX, centerY,
 item.BackColor)
            End If
        End If

        ' If the item is in the rollover state, 
        ' draw a border around it.
        If item.Rollover Then
            ControlPaint.DrawFocusRectangle(e.Graphics, item.ContentRectangle)
        End If
    End If
End Sub
// This method defines the behavior for rendering the
// background of a ToolStripItem. If the item is a
// RolloverItem, it paints the item's BackgroundImage 
// centered in the client area. If the mouse is in the 
// item's client area, a border is drawn around it.
// If the item is on a drop-down or if it is on the
// overflow, a gradient is painted in the background.
protected override void OnRenderItemBackground(
    ToolStripItemRenderEventArgs e)
{
    base.OnRenderItemBackground(e);

    RolloverItem item = e.Item as RolloverItem;

    // If the ToolSTripItem is of type RolloverItem, 
    // perform custom rendering for the background.
    if (item != null)
    {
        if (item.Placement == ToolStripItemPlacement.Overflow
 ||
            item.IsOnDropDown)
        {
            using (LinearGradientBrush b = new
 LinearGradientBrush(
                item.ContentRectangle,
                Color.Salmon,
                Color.DarkRed,
                0f,
                false))
            {
                e.Graphics.FillRectangle(b, item.ContentRectangle);
            }
        }

        // The RolloverItem control only supports 
        // the ImageLayout.Center setting for the
        // BackgroundImage property.
        if (item.BackgroundImageLayout == ImageLayout.Center)
        {
            // Get references to the item's ContentRectangle
            // and BackgroundImage, for convenience.
            Rectangle cr = item.ContentRectangle;
            Image bgi = item.BackgroundImage;

            // Compute the center of the item's ContentRectangle.
            int centerX = (cr.Width - bgi.Width) / 2;
            int centerY = (cr.Height - bgi.Height) / 2;

            // If the item is selected, draw the background
            // image as usual. Otherwise, draw it as disabled.
            if (item.Selected)
            {
                e.Graphics.DrawImage(bgi, centerX, centerY);
            }
            else
            {
                ControlPaint.DrawImageDisabled(
                        e.Graphics,
                        bgi,
                        centerX,
                        centerY,
                        item.BackColor);
            }
        }

        // If the item is in the rollover state, 
        // draw a border around it.
        if (item.Rollover)
        {
            ControlPaint.DrawFocusRectangle(
                e.Graphics,
                item.ContentRectangle);
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ToolStripItemPlacement 列挙体

メモ : この列挙体は、.NET Framework version 2.0新しく追加されたものです。

ToolStripItem をレイアウトする位置指定します

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

Public Enumeration ToolStripItemPlacement
Dim instance As ToolStripItemPlacement
public enum ToolStripItemPlacement
public enum class ToolStripItemPlacement
public enum ToolStripItemPlacement
public enum ToolStripItemPlacement
メンバメンバ
 メンバ説明
MainToolStripItemメイン ToolStrip 上にレイアウトするよう指定します。 
NoneToolStripItem画面上にレイアウトないよう指定します。 
OverflowToolStripItemオーバーフロー ToolStripレイアウトするよう指定します。 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ToolStripItemPlacement」の関連用語

ToolStripItemPlacementのお隣キーワード
検索ランキング

   

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



ToolStripItemPlacementのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS