Solved

Sendmessage, listbox & itemdata

Posted on 1998-02-23
6
1,035 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

688 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