CB_SETCURSEL Message

Platforms

Description & Usage

The CB_SETCURSEL message chooses which item in the list box portion of a combo box control is selected. Doing so erases the user's previous selection, as well as any other text he may have entered in the text box portion of the control.

Return Value

The message returns the zero-based index of the item that is now selected (the first item has an index of 0, etc.). If an error occured, or if the message specified a list box item that does not exist, the message returns -1.

Visual Basic-Specific Issues

None.

Parameters

wParam
The zero-based index of the list box item to select.
lParam
Not used -- set to 0.

Constant Definitions

Const CB_SETCURSEL = &H14E

Example

' This code is licensed according to the terms and conditions listed here.

' Declarations and such needed for the example:
' (Copy them to the (declarations) section of a module.)
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd  _
	As Long, ByVal Msg As Long, wParam As Any, lParam As Any) As Long
Public Const CB_SETCURSEL = &H14E

' Select the second item (index 1) available in the list box portion of the combo
' box control Combo1.
Dim retval As Long  ' return value of message

' Change the current selection of Combo1.
retval = SendMessage(Combo1.hWnd, CB_SETCURSEL, ByVal CLng(1), ByVal CLng(0))

See Also

CB_GETCURSEL

Category

Combo Boxes

Back to the Message list.
Back to the Reference section.


Last Modified: April 16, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/c/cb_setcursel.html