ButtonRenderer.DrawParentBackground メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Shared Sub DrawParentBackground ( _ g As Graphics, _ bounds As Rectangle, _ childControl As Control _ )
Dim g As Graphics Dim bounds As Rectangle Dim childControl As Control ButtonRenderer.DrawParentBackground(g, bounds, childControl)
public static function DrawParentBackground ( g : Graphics, bounds : Rectangle, childControl : Control )

DrawParentBackground メソッドを使用して、カスタム コントロールの領域を塗りつぶすコード例を、次に示します。このコード例は、ButtonRenderer クラスのトピックで取り上げているコード例の一部分です。
' Draw the large or small button, depending on the current state. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) MyBase.OnPaint(e) ' Draw the smaller pressed button image. If state = PushButtonState.Pressed Then ' Set the background color to the parent if visual styles ' are disabled, because DrawParentBackground will only paint ' over the control background if visual styles are enabled. If Application.RenderWithVisualStyles Then Me.BackColor = Color.Azure Else Me.BackColor = Me.Parent.BackColor End If ' If you comment out the call to DrawParentBackground, ' the background of the control will still be visible ' outside the pressed button, if visual styles are enabled. ButtonRenderer.DrawParentBackground(e.Graphics, _ Me.ClientRectangle, Me) ButtonRenderer.DrawButton(e.Graphics, ClickRectangle, _ Me.Text, Me.Font, True, state) ' Draw the bigger unpressed button image. Else ButtonRenderer.DrawButton(e.Graphics, Me.ClientRectangle, _ Me.Text, Me.Font, False, state) End If End Sub
// Draw the large or small button, depending on the current state. protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); // Draw the smaller pressed button image if (state == PushButtonState.Pressed) { // Set the background color to the parent if visual styles // are disabled, because DrawParentBackground will only paint // over the control background if visual styles are enabled. this.BackColor = Application.RenderWithVisualStyles ? Color.Azure : this.Parent.BackColor; // If you comment out the call to DrawParentBackground, // the background of the control will still be visible // outside the pressed button, if visual styles are enabled. ButtonRenderer.DrawParentBackground(e.Graphics, ClientRectangle, this); ButtonRenderer.DrawButton(e.Graphics, ClickRectangle, this.Text, this.Font, true, state); } // Draw the bigger unpressed button image. else { ButtonRenderer.DrawButton(e.Graphics, ClientRectangle, this.Text, this.Font, false, state); } }
// Draw the large or small button, depending on the current state. protected: virtual void OnPaint(PaintEventArgs^ e) override { __super::OnPaint(e); // Draw the smaller pressed button image if (state == PushButtonState::Pressed) { // Set the background color to the parent if visual styles // are disabled, because DrawParentBackground will only paint // over the control background if visual styles are enabled. if (Application::RenderWithVisualStyles) { this->BackColor = Color::Azure; } else { this->BackColor = this->Parent->BackColor; } // If you comment out the call to DrawParentBackground, // the background of the control will still be visible // outside the pressed button, if visual styles are enabled. ButtonRenderer::DrawParentBackground(e->Graphics, ClientRectangle, this); ButtonRenderer::DrawButton(e->Graphics, ClickRectangle, this->Text, this->Font, true, state); } // Draw the bigger unpressed button image. else { ButtonRenderer::DrawButton(e->Graphics, ClientRectangle, this->Text, this->Font, false, state); } }

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に収録されているすべての辞書からButtonRenderer.DrawParentBackground メソッドを検索する場合は、下記のリンクをクリックしてください。

- ButtonRenderer.DrawParentBackground メソッドのページへのリンク