ToolStripItemRenderEventArgs.ToolStrip 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
그릴 Owner의 ToolStripItem 속성 값을 가져옵니다.
public:
property System::Windows::Forms::ToolStrip ^ ToolStrip { System::Windows::Forms::ToolStrip ^ get(); };
public System.Windows.Forms.ToolStrip ToolStrip { get; }
public System.Windows.Forms.ToolStrip? ToolStrip { get; }
member this.ToolStrip : System.Windows.Forms.ToolStrip
Public ReadOnly Property ToolStrip As ToolStrip
속성 값
ToolStrip의 소유자를 나타내는 ToolStripItem입니다.
예제
다음 코드 예제에서는 재정의 하는 방법에 설명 합니다 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 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);
}
}
' 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
설명
경우는 ToolStripItem 넘침 영역에는 Form, ToolStrip 속성이 빈 문자열을 반환 합니다.