property ComboBox.DropDown([Reserved as Variant]) as Boolean
Specifies whether the drop down portion of the control is visible or hidden.

 TypeDescription 
   Reserved as Variant Reserved for future use only.  
   Boolean A boolean expression that indicates whether the drop-down portion of the control is visible or hidden.  

The DropDown property shows or hides the drop down portion of the control. Use the hWndDropDown property to retrieve the handle of the drop down window. The DropDown property has effect only if the control's Style property is DropDown or DropDownList. The control fires the DropDown event when the drop-down portion is shown. The control fires DropUp event when the drop-down portion is hidden. Use the HideDropDownButton property to hide the control's drop down button. Use the DropDown property to retrieve a boolean value that indicates whether the drop down portion of control is visible or hidden. Use the AutoDropDown property to specify whether the drop down portion of the control is shown when user starts type into it. If the Style property is DropDownList you can use the AutoDropDown property on True, and the list will be shown as soon as the user clicks the control's label area. Use the HideDropDownButton property to hide the drop down button. Use the Background property to change the drop down button's visual appearance.

The following VB sample displays the drop down portion of the control when it receives the focus:

Private Sub ComboBox1_GotFocus()
    ComboBox1.DropDown() = True
End Sub

The following VFP sample shows the drop down portion of the control when user clicks the form:

this.EXCOMB.Object.DropDown("") = .t.

where the "EXCOMB" is the name of the control in the VFP screen. In this case, if the Object property is missing it is possible that the VFP environment confuses the DropDown method with the DropDown event, and so an error could occur.

The following samples uses different methods to drop down the control when the user clicks the control's label area. In order to run any of the following sample, please insert the control to a form/dialog, and apply its default template ( so we have loaded columns and items ).

The following VB sample drops down the control when it receives the focus by clicking:

The sample calls the DropDown method when the control gains the focus. 

The following C++ sample shows the drop down portion of the control when the user clicks the control's label area ( WM_PARENTNOTIFY method ):

void OnParentNotify(UINT message, LPARAM lParam) 
{
	CDialog::OnParentNotify(message, lParam);

	if ( LOWORD( message ) == WM_LBUTTONDOWN )
	{
		CRect rtClient;
		m_combobox.GetClientRect( &rtClient );
		m_combobox.ClientToScreen( &rtClient );
		ScreenToClient( &rtClient );
		POINT ptCursor = { ((long)(short)LOWORD(lParam)), ((long)(short)HIWORD(lParam)) };
		if ( PtInRect( &rtClient, ptCursor ) )
		{
			COleVariant vtMissing; V_VT( &vtMissing )= VT_ERROR;
			m_combobox.SetDropDown( vtMissing, TRUE );
		}
	}
	
}

The OnParentNotify method handles the WM_PARENTNOTIFY message of the Dialog class. A parent's OnParentNotify member function is called by the framework when its child window is created or destroyed, or when the user clicks a mouse button while the cursor is over the child window. The m_combobox wraps the control, and it is a member of the dialog class. The sample calls the DropDown method only if the user clicks the control's label area.

The following C# sample displays the drop down portion of the control when user clicks the control's label area:

protected override void DefWndProc( ref Message msg )
{
	base.DefWndProc( ref msg );

	if ( msg.Msg == 0x210 /*WM_PARENTNOTIFY*/ )
	{
		Point pt = new Point( msg.LParam.ToInt32() & 0xFFFF, msg.LParam.ToInt32() >> 16 );
		PointToScreen( pt );
		Control c = GetChildAtPoint(pt);
		if ( c != null )
			if ( c == axComboBox1 )
				axComboBox1.set_DropDown( "", true );
	}
}

The following VB.NET sample displays the drop down portion of the control when the user clicks the control's label area:

Protected Overrides Sub DefWndProc(ByRef m As Message)
    MyBase.DefWndProc(m)

    If (m.Msg = &H210) Then 'WM_PARENTNOTIFY
        Dim pt As Point
        pt.X = m.LParam.ToInt32() And &HFFFF
        pt.Y = m.LParam.ToInt32() / 65536
        Dim c As Control
        c = GetChildAtPoint(pt)
        If Not (c Is Nothing) Then
            If c Is AxComboBox1 Then
                AxComboBox1.set_DropDown("", True)
            End If
        End If
    End If
End Sub

The following VFP sample displays the drop down message when the control gains the focus by clicking the control's label area ( the code should be put on ComboBox1.GotFocus event ):

DECLARE LONG GetMessagePos IN user32

DECLARE LONG WindowFromPoint IN user32; 
	LONG   x,; 
	LONG   y
	
DECLARE LONG IsChild IN user32;
	LONG   hWndParent,; 
	LONG   hWnd

local x, y
x = Bitand(GetMessagePos(),4095)
y = Int(GetMessagePos() / 65536)
with thisform.ComboBox1
	if ( 0 # IsChild( .hWnd(), WindowFromPoint( x, y ) ) )
		.Object.DropDown("") = .t.
	endif
endwith  
  


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.