Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tlistview selection

5 views
Skip to first unread message

Jeff Kish

unread,
Jun 6, 2008, 4:11:37 PM6/6/08
to
can someone tell me how to programmatically select, say, the 10th row
(index 9) in a tlistview object?
borland 5.02

I'm not clear about the masks and states.

thanks
Jeff

Bruce Salzman

unread,
Jun 6, 2008, 5:20:53 PM6/6/08
to

"Jeff Kish" <kish...@charter.net> wrote in message
news:be6j44h6f0at06sqp...@4ax.com...

Since it is derived from TListBox, try SelSelIndex(9).

--
Bruce

Ray Sittig

unread,
Jun 9, 2008, 3:16:53 PM6/9/08
to
For multiple-selection list boxes: SetSel(9, true);
For single-selection list boxes: SetSelIndex(9);

Ray Sittig

"Jeff Kish" <kish...@charter.net> wrote in message
news:be6j44h6f0at06sqp...@4ax.com...

Jeff Kish

unread,
Jun 9, 2008, 10:22:55 PM6/9/08
to
On Fri, 6 Jun 2008 16:20:53 -0500, " Bruce Salzman" <br...@nospam.org>
wrote:

well, darn... that sounds way too easy...
I just didn't notice that for some odd reason, and ended up doing
this:

for (int nIndex = 0; nIndex < myTListView->GetItemCount(); nIndex++)
{
myTListView->GetItemText(nIndex, 0, buffer, 1024);
string strData = buffer;
if (strData == strTargetData)
{
myTListView->EnsureVisible(nIndex,false);
uint uState, uRetrievalState;
uRetrievalState = LVIS_SELECTED;
uState = myTListView->GetItemState(nIndex,uRetrievalState);
myTListView->SetItemState(nIndex,uRetrievalState,uRetrievalState);
break;
}
}
Your code looks so much more sensible... than the

myTListView->EnsureVisible(nIndex,false);
uint uState, uRetrievalState;
uRetrievalState = LVIS_SELECTED;
uState = myTListView->GetItemState(nIndex,uRetrievalState);
myTListView->SetItemState(nIndex,uRetrievalState,uRetrievalState);


thanks Bruce.
Jeff

Jeff Kish

unread,
Jun 9, 2008, 10:24:40 PM6/9/08
to

sigh. I wish a little more common sense would leak into my brain at
opportune moments.. I decided when I coded this up that because I
never use the tlistview object, that it was a bit complex and went
along with that assumption instead of taking a step back and looking
at what is obviously... the more general and obvious approach.

Thanks again
Jeff

0 new messages