Sendmessage, listbox & itemdata

I can, with sendmessage, fill the text of a listbox.
But, how, with sendmessage, fill the itemdata of a listbox?
Code needed.
Who is Participating?
mrmickConnect With a Mentor Commented:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Assuming a listbox named "List1" has data, Index contains the index of the item and longData contains the value to be assinged to ItemData.  RC = Return Code.

RC = SendMessage(List1.hwnd, LB_SETITEMDATA, Index, longData)
Not sure about this, but ItemData appears to be an extension of the standard Microsoft listbox.  The VB control provides this, above and beyond a listbox.  Also in C++, the object wrapper around the listbox appears to provide the itemdata property.

But...hang on for more comments..cause I could be wrong.
You can find examples that demonstrate using sendmessage and the listbox as well as many other great VB examples at the following URL:

Click Code Library on the left, List & Combo on the center left.

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

trodriAuthor Commented:
Sorry, i need code here
trodriAuthor Commented:
Thanks very much, but....
i try this code using a combobox and i can put values in text using: rc = SendMessage(Combo1.hwnd, CB_ADDSTRING, 0, ByVal ja)
but i can't put any values on itemdata!!! In the two cases, rc is 0.
Can you help me? I give you the points, of course!
Sorry, that's because to set itemdata values in a combobox you must use


instead of the LB_SETITEMDATA

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.