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

Public Shared Sub DrawDropDownButton ( _ g As Graphics, _ bounds As Rectangle, _ state As ComboBoxState _ )
Dim g As Graphics Dim bounds As Rectangle Dim state As ComboBoxState ComboBoxRenderer.DrawDropDownButton(g, bounds, state)
public static function DrawDropDownButton ( g : Graphics, bounds : Rectangle, state : ComboBoxState )



カスタム コントロールの OnPaint メソッドで DrawDropDownButton メソッドを使用して、マウス ポインタの位置によって決定される状態のドロップダウン矢印を描画するコード例を次に示します。このコード例は、ComboBoxRenderer クラスのトピックで取り上げているコード例の一部分です。
' Draw the combo box in the current state. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) MyBase.OnPaint(e) If Not ComboBoxRenderer.IsSupported Then Me.Parent.Text = "Visual Styles Disabled" Return End If Me.Parent.Text = "CustomComboBox Enabled" ' Always draw the main text box and drop down arrow in their ' current states. ComboBoxRenderer.DrawTextBox(e.Graphics, topTextBoxRectangle, _ Me.Text, Me.Font, textBoxState) ComboBoxRenderer.DrawDropDownButton(e.Graphics, arrowRectangle, _ arrowState) ' Only draw the bottom text box if the arrow has been clicked. If isActivated Then ComboBoxRenderer.DrawTextBox(e.Graphics, _ bottomTextBoxRectangle, bottomText, Me.Font, textBoxState) End If End Sub Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) MyBase.OnMouseDown(e) ' Check whether the user clicked the arrow. If arrowRectangle.Contains(e.Location) And _ ComboBoxRenderer.IsSupported Then ' Draw the arrow in the pressed state. arrowState = ComboBoxState.Pressed ' The user has activated the combo box. If Not isActivated Then Me.Text = "Clicked!" textBoxState = ComboBoxState.Pressed isActivated = True ' The user has deactivated the combo box. Else Me.Text = "Click here" textBoxState = ComboBoxState.Normal isActivated = False End If ' Redraw the control. Invalidate() End If End Sub
// Draw the combo box in the current state. protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (!ComboBoxRenderer.IsSupported) { this.Parent.Text = "Visual Styles Disabled"; return; } this.Parent.Text = "CustomComboBox Enabled"; // Always draw the main text box and drop down arrow in their // current states ComboBoxRenderer.DrawTextBox(e.Graphics, topTextBoxRectangle, this.Text, this.Font, textBoxState); ComboBoxRenderer.DrawDropDownButton(e.Graphics, arrowRectangle, arrowState); // Only draw the bottom text box if the arrow has been clicked if (isActivated) { ComboBoxRenderer.DrawTextBox(e.Graphics, bottomTextBoxRectangle, bottomText, this.Font, textBoxState); } } protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); // Check whether the user clicked the arrow. if (arrowRectangle.Contains(e.Location) && ComboBoxRenderer.IsSupported) { // Draw the arrow in the pressed state. arrowState = ComboBoxState.Pressed; // The user has activated the combo box. if (!isActivated) { this.Text = "Clicked!"; textBoxState = ComboBoxState.Pressed; isActivated = true; } // The user has deactivated the combo box. else { this.Text = "Click here"; textBoxState = ComboBoxState.Normal; isActivated = false; } // Redraw the control. Invalidate(); } }
// Draw the combo box in the current state. protected: virtual void OnPaint(PaintEventArgs^ e) override { Control::OnPaint(e); if (!ComboBoxRenderer::IsSupported) { this->Parent->Text = "Visual Styles Disabled"; return; } this->Parent->Text = "CustomComboBox Enabled"; // Always draw the main text box and drop down arrow in their // current states ComboBoxRenderer::DrawTextBox(e->Graphics, topTextBoxRectangle, this->Text, this->Font, textBoxState); ComboBoxRenderer::DrawDropDownButton(e->Graphics, arrowRectangle, arrowState); // Only draw the bottom text box if the arrow has been clicked if (isActivated) { ComboBoxRenderer::DrawTextBox(e->Graphics, bottomTextBoxRectangle, bottomText, this->Font , textBoxState); } } protected: virtual void OnMouseDown(MouseEventArgs^ e) override { Control::OnMouseDown(e); // Check whether the user clicked the arrow. if (arrowRectangle.Contains(e->Location) && ComboBoxRenderer::IsSupported) { // Draw the arrow in the pressed state. arrowState = ComboBoxState::Pressed; // The user has activated the combo box. if (!isActivated) { this->Text = "Clicked!"; textBoxState = ComboBoxState::Pressed; isActivated = true; } // The user has deactivated the combo box. else { this->Text = "Click here"; textBoxState = ComboBoxState::Normal; isActivated = false; } // Redraw the control. Invalidate(); } }

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

- ComboBoxRenderer.DrawDropDownButton メソッドのページへのリンク