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

ListView Row Highlight

387 views
Skip to first unread message

Rick Carter

unread,
Jul 17, 2002, 5:08:21 PM7/17/02
to

I've got a ListView with RowSelect = True.
I'm populating the items at runtime.
If there is only one item, I want that row to be highlighted,
as if I had clicked it with the mouse.

So far I've tried:
ItemIndex := 0;
onClick.Sender;
ItemFocused := Items[0];
as well as the combination of:
Selected := Items[0];
Selected.MakeVisible(False);

Any one of those lines will trigger the "onSelectItem" method,
but none of them will highlight the row for me.

Rick Carter
Rick....@cincww.rcc.org
Chair, Paradox/Delphi SIG, Cincinnati PC Users Group

Rick Carter

unread,
Jul 17, 2002, 5:15:17 PM7/17/02
to

"Rick Carter" <Rick....@cincww.rcc.org> wrote:
> onClick.Sender;
Typo! Actually, what I tried was:
onClick(Sender);

G Sharpe

unread,
Jul 17, 2002, 5:57:18 PM7/17/02
to
Rick Carter wrote:

I think the listview maybe not have focus and
that the listview's HideSelection property is
maybe set true.
-
Grant

Alvin Lee

unread,
Jul 17, 2002, 7:55:37 PM7/17/02
to
"Rick Carter" <Rick....@cincww.rcc.org> wrote in news:3d35de65$1_1
@dnews:

Try:

MyListView.Items[0].Selected := True;

Also, does your ListView have the focus?

--
Alvin Lee

"The new approach is still about people; it's just that before we
were for them and now we're against them." --Harvard Business Review

Bevan Arps

unread,
Jul 17, 2002, 9:48:05 PM7/17/02
to
In article <3d35de65$1_1@dnews>, Rick....@cincww.rcc.org says...

> Typo! Actually, what I tried was:
> onClick(Sender);

Whoah!

I think others in this thread will have solved your problem for you -
assigning to Selected DOES work.

A small note though - I've found it to be bad practice to directly call
events directly. If you can't work out why for yourself, start a new
thread and see what people say. ;-)

Cheers,
Bevan.

Rick Carter

unread,
Jul 18, 2002, 11:32:00 AM7/18/02
to

G Sharpe <nos...@nospam.com> wrote:
>I think the listview maybe not have focus and
>that the listview's HideSelection property is
>maybe set true.

Exactly right! Either setting the ListView's HideSelection
property to False, or first calling
Active Control := ListView1;
did the job.

Thanks, this had me stumped for a while!

0 new messages