Solved

Sendmessage, listbox & itemdata

Posted on 1998-02-23
6
1,029 Views
Last Modified: 2008-02-01
Hello
I can, with sendmessage, fill the text of a listbox.
But, how, with sendmessage, fill the itemdata of a listbox?
Code needed.
Regards
0
Comment
Question by:trodri
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:rmichels
ID: 1457707
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.
0
 
LVL 8

Expert Comment

by:mrmick
ID: 1457708
You can find examples that demonstrate using sendmessage and the listbox as well as many other great VB examples at the following URL:

http://home.sprynet.com/sprynet/rasanen/vbnet/default.htm

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

0
 

Author Comment

by:trodri
ID: 1457709
Sorry, i need code here
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 8

Accepted Solution

by:
mrmick earned 100 total points
ID: 1457710
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
Const LB_SETITEMDATA = &H19A

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)
0
 

Author Comment

by:trodri
ID: 1457711
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!
Regards
0
 
LVL 8

Expert Comment

by:mrmick
ID: 1457712
Sorry, that's because to set itemdata values in a combobox you must use

Const CB_SETITEMDATA = &H151

instead of the LB_SETITEMDATA



0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now