Check if listview item is selected c#

How do you stop a ListView having no selected Items?

=?Utf-8?B?TWFyayBDb2xsYXJk?=
Hello

I've added a listview to my WinForms C# 2.0 application. The listview is
displayed in Details view and has the FullRowSelect property set to true. I'm
using the listview control like a multi column list box [with column
headers], and I've set the MultiSelect property to false. It all works fine
apart from the user can unselect the selected listviewitem by clicking in a
blank area of the listview.

I could add some code in the SelectedIndexChanged event to check if all the
items are unselected and select the previously selected item, but this causes
the listview to flicker. There must be a better way.

How can I make sure the ListView always has a selected lsitviewitem?

Thank you for your help.
Nov 2 '07 #1
Follow Post Reply
1 3349
Alexander Vasilevsky
Please use ListView BeginUpdate[] and EndUpdate[] methods.

--
//www.alvas.net - Audio tools for C# and VB.Net developers
"Mark Collard"

Chủ Đề