• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Listbox in Win32 GUI

Psychohyena

New Member
Joined
Jan 10, 2010
Messages
9 (0.00/day)
Hi peeps,

I'm putting together a Win32 app (API) and crazy me decided to do it in c++ coding (no visual editors). The problem I've run into is I'm filling a listbox with data from a database, the obvious result of this is that the index value of the items are going to be different from the Primary Key value in the database.

My question is: How can I link the Primary Key to the correct record in the Listbox and use that value rather than the index value?

So far I have managed to get most of the app worked out but this is creating a major stumbling block for having everything work smoothly.

Let me know if you need any more information.
 
You can bind the data to the ListBox. and then set the DisplayMember property to what you want displayed in the listbox, and set the ValueMember property to the PK in the database.
 
use LB_SETITEMDATA
 
Thanks for the suggestions guys. While it didn't help me achieve what I wanted it did help me realise that at my current skill level the way I was doing the application was ambitious and above my current capabilities. Though it does give me something to aim for, for now I'll use a visual developing environment.
 
Back
Top