How to set un-editable column in Listview?

keirnus

Registered User.
Local time
Today, 16:42
Joined
Aug 12, 2008
Messages
99
Hello,

I have a Listview control which displays various data.
The default selected item is the first item.
(Is it always the first item?)

Here's a simple code:
Code:
    Dim objListItem As Object
 
    lstvwXclList.View = lvwReport
    ' Set column headers 
    With lstvwXclList.ColumnHeaders
        .Add , , "Activity", 4000
        .Add , , "Description", 4700, lvwColumnLeft
        .Add , , "Filename", 2400, lvwColumnRight
    End With
 
    Set objListItem = lstvwXclList.ListItems.Add()
    objListItem.Text = "Swimming"
    objListItem.SubItems(1) = "400 m Freestyle"
    objListItem.SubItems(2) = "Swimming.xls"

The only clickable column is the first column.
In this case, the "Activity" column.

The problem here is the data in "Activity" column is editable.
The data need not to be edited. It must stay as is.

What to do in order to set it un-editable?
Haven't found any settings in the control's properties.

Help from the experts and the knowledgable are greatly appreciated.
 
are you by any chance useing a third party list box object or one that isnt in access default library ? i have worked hard to make a list box editable but the closest to it was a 10 line of code leap , so how is ur control doing it ?
 
are you by any chance useing a third party list box object or one that isnt in access default library ? i have worked hard to make a list box editable but the closest to it was a 10 line of code leap , so how is ur control doing it ?

Actually, it is a ListView Object.

--------------------------------------
Microsoft ListView Control 6.0 (SP6)

Class: MSComctlLib.ListViewCtrl.2
OLE Class: ListViewCtrl
--------------------------------------

Only one column is editable.
The one with the expression.Text which is my "Activity" column.

There is no property for "edit enable" or something like that.
Hope someone could help me on this.
 
Ok i have tried to work with that control but it returns OLE object non registered for me , however i could access its properties but it's very limited as u have noted.
however here goes a trick that works under all conditions :
in On Got Focus event property use :

Form.Allowedits = False

And On Lose Focus event :

Form.Allowedits = True

Also if by any chance you trigger Form.Allowedits through any other control and you want to save that status u can always create a global variable that stores its status on control getting focus then restoring it than rather setting it to true on losing it.
 
Ok i have tried to work with that control but it returns OLE object non registered for me , however i could access its properties but it's very limited as u have noted.
however here goes a trick that works under all conditions :
in On Got Focus event property use :

Form.Allowedits = False

And On Lose Focus event :

Form.Allowedits = True

Also if by any chance you trigger Form.Allowedits through any other control and you want to save that status u can always create a global variable that stores its status on control getting focus then restoring it than rather setting it to true on losing it.

hmmm...that could work...
i'll try that trick...

thanks for the advice!
 
SOLVED: How to set un-editable column in Listview?

I finally got it! :)

I added this setting:
Code:
lstvwXclList.LabelEdit = lvwManual

Changing this property in VB Editor seems to be buggy.
No matter what value I set, it always reverts to its original value.
(weird)

I also tried implementing this:
Form.Allowedits = False/True

Unfortunately, it doesn't work.
Seems like the ListView is not affected by this setting.
(Dunno yet why)

Anyway, this issue is considered SOLVED.

Thanks to you, nIGHTmAYOR!
(...for giving time and effort on this issue.)
 
Re: SOLVED: How to set un-editable column in Listview?

....

Changing this property in VB Editor seems to be buggy.
No matter what value I set, it always reverts to its original value.
(weird)

....

I now know why setting the properties of ListView control in
VB Editor doesn't work. It is because the ListView has its own
"Property" setting. :eek:

The pre-defined Property Setting link is the "Properties".
But the ListView's link is "ListViewCtrl Object".
Please refer to attached image.

listviewpropertysettingns7.png


No wonder why my settings were not reflected.

Weirdness of the ListView Property Setting solved. :cool:

(Signing off)
 
interesting , have u tried this ?
Code:
lstvwXclList.Locked = true
 

Users who are viewing this thread

Back
Top Bottom