.NET Framework - Making Listview Columns Read Only

Asked By CaptainCaveman on 05-Mar-09 10:42 AM

Is it possible to make a listview column read only?
If so, how is it possible?



Jeff Johnson replied on 05-Mar-09 11:36 AM
Define "read-only." List views are by default 100% read-only in that you
cannot change their values (LabelEdit is false). Are you perhaps talking
about resizing?
CaptainCaveman replied on 06-Mar-09 07:14 AM
Hi Jeff,

Although I agree that the data should not be editable in a ListView cell, I
am finding that if I treble click in the first column I am able to edit the
text. The cell text becomes surrounded by square brackets, e.g. [My Text],
and I am therefore able to edit the text.

I already handle the double click, but it seems the third click makes the
cell editable.

Any further help would be much appreciated.

Jeff Johnson replied on 06-Mar-09 10:09 AM
You've got something else going on. Is this a plain vanilla list view?
Select it in Design view in Visual Studio and then look at the Properties
window. In the dropdown at the top you'll see the name of the control (in
bold) followed by the class name. (You may have to increase the width of the
Properties window to see the full name.) Is it

I put a regular list view on a form, added three items to it, and it never
exhibited the behavior you described. I tried several different views, too
(Details, List, etc.).
Dad replied on 06-Mar-09 11:34 AM
The first column is editable unless you set "LabelEdit" false in Properties.
The other columns are always read only.  Just go to Properties and set

Jeff Johnson replied on 06-Mar-09 12:20 PM
In .NET 2.0 (at least), LabelEdit is false by default, so there should be no
need to set it to false unless you previously set it to true.