Sending the CB_DELETESTRING message to a combo box removes one of the items from its drop-down box.
If successful, the message returns the number of items remaining in the combo box's drop-down box. If an error occured, the message returns CB_ERR.
None.
Const CB_DELETESTRING = &H144
Const CB_ERR = -1
When the user clicks button Command1, remove the second item from combo box's Combo1 drop-down box. To run this example, place a combo box named Combo1 and a command button named Command1 on a form window.
' 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_DELETESTRING = &H144
Public Const CB_ERR = -1
' *** Place the following code inside a form window. ***
Private Sub Command1_Click()
Dim result As Long ' result of string deletion attempt
' Remove the second item from Combo1's drop-down list
' box, and display the result.
result = SendMessage(Combo1.hWnd, CB_DELETESTRING, ByVal CLng(1), ByVal CLng(0))
If result = CB_ERR Then
Debug.Print "Unable to delete the second string in Combo1's drop-down box."
Else
Debug.Print "There are"; result; "strings left in Combo1's drop-down box."
End If
End Sub
CB_ADDSTRING, CB_INSERTSTRING, CB_RESETCONTENT
Back to the Message list.
Back to the Reference section.
Last Modified: September 24, 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_deletestring.html