ListBox Click Function

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

ListBox Click Function

Postby AlBro » Mon Apr 13, 2015 9:14 am

Noticed that there is no click function with the ListBox component. Tried coding the ListBox to fire properly when the Itemindex is preset but the info is not doing what I intended. Should there be a Click function considering there is an OnClick event and this links to a ListBoxClick handler. Maybe a better method someone may know...
AlBro
 
Posts: 4
Joined: Mon Apr 13, 2015 9:00 am

Re: ListBox Click Function

Postby 2ffat » Mon Apr 13, 2015 10:09 am

Tried coding the ListBox to fire properly when the Itemindex is preset but the info is not doing what I intended.

Post the code and tell us what you had intended.
James P. Cottingham

Look at me still talking
when there is science to do.
User avatar
2ffat
Forum Mod
Forum Mod
 
Posts: 433
Joined: Wed Jun 23, 2004 7:07 am
Location: South Hill, VA

Re: ListBox Click Function

Postby rlebeau » Mon Apr 13, 2015 12:57 pm

Every VCL component has a protected Click() method inherited from TControl, which triggers the OnClick event. Some controls, like TButton, expose public access to Click(). Most controls do not, including TListBox. But you can use an accessor class to call the protected Click() if needed, eg:

Code: Select all
class TListBoxClickAccess : public TListBox
{
public:
    using TListBox::Click;
};

((TListBoxClickAccess*)ListBox1)->Click();
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1528
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA


Return to Technical

Who is online

Users browsing this forum: No registered users and 13 guests