ToolStripItem.ContentRectangle プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

ToolStripItem の境界線以外のコンテンツの位置とサイズを表す 4 つの整数を格納する Rectangle。


ContentRectangle プロパティを使ったカスタム レンダリングの方法を、次のコード例に示します。このコード例は、ToolStripItem クラスのトピックで取り上げているコード例の一部分です。
' This utility method computes the layout of the ' RolloverItem control's image area and the text area. ' For brevity, only the following settings are ' supported: ' ' ToolStripTextDirection.Horizontal ' TextImageRelation.ImageBeforeText ' TextImageRelation.ImageBeforeText ' ' It would not be difficult to support vertical text ' directions and other image/text relationships. Private Sub ComputeImageAndTextLayout() Dim cr As Rectangle = MyBase.ContentRectangle Dim img As Image = MyBase.Owner.ImageList.Images(MyBase.ImageKey) ' Compute the center of the item's ContentRectangle. Dim centerY As Integer = (cr.Height - img.Height) / 2 ' Find the dimensions of the image and the text ' areas of the item. The text occupies the space ' not filled by the image. If MyBase.TextImageRelation = _ TextImageRelation.ImageBeforeText AndAlso _ MyBase.TextDirection = ToolStripTextDirection.Horizontal Then imageRect = New Rectangle( _ MyBase.ContentRectangle.Left, _ centerY, _ MyBase.Image.Width, _ MyBase.Image.Height) textRect = New Rectangle( _ imageRect.Width, _ MyBase.ContentRectangle.Top, _ MyBase.ContentRectangle.Width - imageRect.Width, _ MyBase.ContentRectangle.Height) ElseIf MyBase.TextImageRelation = _ TextImageRelation.TextBeforeImage AndAlso _ MyBase.TextDirection = ToolStripTextDirection.Horizontal Then imageRect = New Rectangle( _ MyBase.ContentRectangle.Right - MyBase.Image.Width, _ centerY, _ MyBase.Image.Width, _ MyBase.Image.Height) textRect = New Rectangle( _ MyBase.ContentRectangle.Left, _ MyBase.ContentRectangle.Top, _ imageRect.X, _ MyBase.ContentRectangle.Bottom) End If End Sub End Class
// This utility method computes the layout of the // RolloverItem control's image area and the text area. // For brevity, only the following settings are // supported: // // ToolStripTextDirection.Horizontal // TextImageRelation.ImageBeforeText // TextImageRelation.ImageBeforeText // // It would not be difficult to support vertical text // directions and other image/text relationships. private void ComputeImageAndTextLayout() { Rectangle cr = base.ContentRectangle; Image img = base.Owner.ImageList.Images[base.ImageKey]; // Compute the center of the item's ContentRectangle. int centerY = (cr.Height - img.Height) / 2; // Find the dimensions of the image and the text // areas of the item. The text occupies the space // not filled by the image. if (base.TextImageRelation == TextImageRelation.ImageBeforeText && base.TextDirection == ToolStripTextDirection.Horizontal) { imageRect = new Rectangle( base.ContentRectangle.Left, centerY, base.Image.Width, base.Image.Height); textRect = new Rectangle( imageRect.Width, base.ContentRectangle.Top, base.ContentRectangle.Width - imageRect.Width, base.ContentRectangle.Height); } else if (base.TextImageRelation == TextImageRelation.TextBeforeImage && base.TextDirection == ToolStripTextDirection.Horizontal) { imageRect = new Rectangle( base.ContentRectangle.Right - base.Image.Width , centerY, base.Image.Width, base.Image.Height); textRect = new Rectangle( base.ContentRectangle.Left, base.ContentRectangle.Top, imageRect.X, base.ContentRectangle.Bottom); } }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からToolStripItem.ContentRectangle プロパティを検索する場合は、下記のリンクをクリックしてください。

- ToolStripItem.ContentRectangle プロパティのページへのリンク