473,387 Members | 1,628 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do you stop a ListView having no selected Items?

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
1 3741
Please use ListView BeginUpdate() and EndUpdate() methods.

--
http://www.alvas.net - Audio tools for C# and VB.Net developers
"Mark Collard" <Ma*********@discussions.microsoft.comсообщил/сообщила в
новостях следующее:
news:73**********************************@microsof t.com...
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 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Maheshkumar.R | last post by:
hi groups, I have placed an listview control, i want to iterate thru the control and find the clicked event items. listView2.Items.Add(fname.ToString(), i); how i can perform the iteration...
1
by: cider123 | last post by:
I've tried working with the SelectedIndices and Items.Selected attributes to get the problem to go away, but not having any luck. Questions I have are: 1) How do you move (using code) the...
1
by: Shane | last post by:
I have a text box select items in a listview as text is being typed into the text box. I get the select bar to move correctly in the Listview control. If the user presses the down or up key in...
4
by: Shane | last post by:
I have a text box select items in a listview as text is being typed into the text box. I get the select bar to move correctly in the Listview control. If the user presses the down or up key in...
21
by: StriderBob | last post by:
Situation : FormX is mdi child form containing 2 ListViews ListView1 contains a list of table names and 4 sub items with data about each table. ListView2 contains a list of the columns on each...
1
by: Chris | last post by:
Hi all, I posted the following in microsoft.public.dotnet.framework.windowsforms but it seems that group has little traffic. Hi all, I have a listview box which is populated from methods of...
2
by: Mike | last post by:
Ok I'm having a problem with a listview. I have a listview on a WinForm called ProgramInformationFrm. I call this from from 2 other forms. One is ProgramSearch Frm, the other is OpenNCFrm. The...
5
by: Phill W. | last post by:
(VB'2003) What's the correct way to remove multiple, selected items from a ListView control (say, from a ContextMenu)? I ask because I'm getting a very annoying ArgumentOutOfRangeException...
0
by: lsharva | last post by:
Actually, i m working on Windows Application where i have to use the ComboBox and listview in a way , as first we will click the comboBox and then as you click , ListView appear and when we...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.