Article View: borland.public.cppbuilder.nativeapi
Article #9409Re: Problem with a sorted combobox
From: Remy Lebeau (TeamB)
Date: Sat, 10 Jul 2004 19:24
Date: Sat, 10 Jul 2004 19:24
36 lines
2178 bytes
2178 bytes
"Zlika" <zlika_eseSTOPSPAM@hotmail.com> wrote in message
news:40f03f38$1@newsgroups.borland.com...
> I have a problem with the TComboBox component.
> I've got a sorted ComboBox. To know which item is selected (because the
> combobox is sorted), I first assign each item a ID through the Perform
> method:
Why do you need an ID to know which item is selected? The ItemIndex
property already tells you exactly which item is selected. What exactly are
you trying to accomplish by assigning IDs manually?
> ComboBox->Perform(LB_SETITEMDATA,pos,i);
You are sending a ListBox message to a ComboBox. That will not work. You
should be using CB_SETITEMDATA instead of LB_SETITEMDATA. Or, just use the
Objects[] property instead and let the component handle the messages for you
internally:
ComboBox->Items->Objects[pos] = reinterpret_cast<void*>(i);
> number = ComboBox->Perform(LB_GETITEMDATA,ComboBox->ItemIndex,0);
Likewise, use CB_GETITEMDATA instead of LB_GETITEMDATA. Or else use the
Objects[] property:
number =
reinterpret_cast<int>(ComboBox->Items->Objects[ComboBox->ItemIndex]);
> However, this last command always return 0!
That is because you are using the wrong messages to begin with.
Gambit
Technical Details
Message-ID:
<40f04255@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40f03f38$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,c046cfa35a952d0b X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40f03f38$1@newsgroups.borland.com> Subject: Re: Problem with a sorted combobox Date: Sat, 10 Jul 2004 12:24:37 -0700 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.10 Message-ID: <40f04255@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1089487445 68.69.17.10 (10 Jul 2004 12:24:05 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail