ToolStripItemRenderEventArgs クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


ToolStripItemRenderEventArgs クラスでは、次のイベントに関するデータが提供されます。
-
RenderButtonBackground
-
RenderDropDownButtonBackground
-
RenderItemBackground
-
RenderLabelBackground
-
RenderMenuItemBackground
-
RenderOverflowButtonBackground
-
RenderSplitButtonBackground
-
DrawButtonBackground
-
DrawDropDownButtonBackground
-
DrawItemBackground
-
DrawLabelBackground
-
DrawMenuItemBackground
-
DrawOverflowButtonBackground
-
DrawSplitButton

OnRenderButtonBackground メソッドをオーバーライドして、ToolStripButton コントロールの Image の周囲に境界線を描画する方法を次のコード例に示します。このコード例は、ToolStripRenderer クラスのトピックで取り上げているコード例の一部分です。
' This method draws a border around the button's image. If the background ' to be rendered belongs to the empty cell, a string is drawn. Otherwise , ' a border is drawn at the edges of the button. Protected Overrides Sub OnRenderButtonBackground(e As ToolStripItemRenderEventArgs) MyBase.OnRenderButtonBackground(e) ' Define some local variables for convenience. Dim g As Graphics = e.Graphics Dim gs As GridStrip = e.ToolStrip Dim gsb As ToolStripButton = e.Item ' Calculate the rectangle around which the border is painted. Dim imageRectangle As New Rectangle(borderThickness, borderThickness, e.Item.Width - 2 * borderThickness, e.Item.Height - 2 * borderThickness) ' If rendering the empty cell background, draw an ' explanatory string, centered in the ToolStripButton. If gsb Is gs.EmptyCell Then e.Graphics.DrawString("Drag to here", gsb.Font, SystemBrushes.ControlDarkDark, imageRectangle, style) Else ' If the button can be a drag source, paint its border red. ' otherwise, paint its border a dark color. Dim b As Brush = IIf(gs.IsValidDragSource(gsb), Brushes.Red, SystemBrushes.ControlDarkDark) ' Draw the top segment of the border. Dim borderSegment As New Rectangle(0, 0, e.Item.Width, imageRectangle.Top) g.FillRectangle(b, borderSegment) ' Draw the right segment. borderSegment = New Rectangle(imageRectangle.Right, 0, e.Item.Bounds.Right - imageRectangle.Right, imageRectangle.Bottom) g.FillRectangle(b, borderSegment) ' Draw the left segment. borderSegment = New Rectangle(0, 0, imageRectangle.Left, e.Item.Height) g.FillRectangle(b, borderSegment) ' Draw the bottom segment. borderSegment = New Rectangle(0, imageRectangle.Bottom, e.Item.Width, e.Item.Bounds.Bottom - imageRectangle.Bottom) g.FillRectangle(b, borderSegment) End If End Sub End Class
// This method draws a border around the button's image. If the background // to be rendered belongs to the empty cell, a string is drawn. Otherwise , // a border is drawn at the edges of the button. protected override void OnRenderButtonBackground( ToolStripItemRenderEventArgs e) { base.OnRenderButtonBackground(e); // Define some local variables for convenience. Graphics g = e.Graphics; GridStrip gs = e.ToolStrip as GridStrip; ToolStripButton gsb = e.Item as ToolStripButton; // Calculate the rectangle around which the border is painted. Rectangle imageRectangle = new Rectangle( borderThickness, borderThickness, e.Item.Width - 2 * borderThickness, e.Item.Height - 2 * borderThickness); // If rendering the empty cell background, draw an // explanatory string, centered in the ToolStripButton. if (gsb == gs.EmptyCell) { e.Graphics.DrawString( "Drag to here", gsb.Font, SystemBrushes.ControlDarkDark, imageRectangle, style); } else { // If the button can be a drag source, paint its border red. // otherwise, paint its border a dark color. Brush b = gs.IsValidDragSource(gsb) ? b = Brushes.Red : SystemBrushes.ControlDarkDark; // Draw the top segment of the border. Rectangle borderSegment = new Rectangle( 0, 0, e.Item.Width, imageRectangle.Top); g.FillRectangle(b, borderSegment); // Draw the right segment. borderSegment = new Rectangle( imageRectangle.Right, 0, e.Item.Bounds.Right - imageRectangle.Right, imageRectangle.Bottom); g.FillRectangle(b, borderSegment); // Draw the left segment. borderSegment = new Rectangle( 0, 0, imageRectangle.Left, e.Item.Height); g.FillRectangle(b, borderSegment); // Draw the bottom segment. borderSegment = new Rectangle( 0, imageRectangle.Bottom, e.Item.Width, e.Item.Bounds.Bottom - imageRectangle.Bottom); g.FillRectangle(b, borderSegment); } }

System.EventArgs
System.Windows.Forms.ToolStripItemRenderEventArgs
System.Windows.Forms.ToolStripItemImageRenderEventArgs
System.Windows.Forms.ToolStripItemTextRenderEventArgs
System.Windows.Forms.ToolStripSeparatorRenderEventArgs


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ToolStripItemRenderEventArgs コンストラクタ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim g As Graphics Dim item As ToolStripItem Dim instance As New ToolStripItemRenderEventArgs(g, item)

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ToolStripItemRenderEventArgs プロパティ

名前 | 説明 | |
---|---|---|
![]() | Graphics | ToolStripItem の描画に使用するグラフィックスを取得します。 |
![]() | Item | 描画する ToolStripItem を取得します。 |
![]() | ToolStrip | 描画する ToolStripItem の ToolStripItem.Owner プロパティの値を取得します。 |

ToolStripItemRenderEventArgs メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

ToolStripItemRenderEventArgs メンバ
ToolStripItem から派生したオブジェクトの背景を描画する、ToolStripRenderer クラスのイベントに関するデータを提供します。
ToolStripItemRenderEventArgs データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | ToolStripItemRenderEventArgs | 指定した Graphics を使用して、指定した ToolStripItem の ToolStripItemRenderEventArgs クラスの新しいインスタンスを初期化します。 |

名前 | 説明 | |
---|---|---|
![]() | Graphics | ToolStripItem の描画に使用するグラフィックスを取得します。 |
![]() | Item | 描画する ToolStripItem を取得します。 |
![]() | ToolStrip | 描画する ToolStripItem の ToolStripItem.Owner プロパティの値を取得します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- ToolStripItemRenderEventArgsのページへのリンク