473,397 Members | 2,033 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,397 software developers and data experts.

How to set un-editable column in Listview?

48
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:
Expand|Select|Wrap|Line Numbers
  1.     Dim objListItem As Object
  2.  
  3.     lstvwXclList.View = lvwReport
  4.     ' Set column headers 
  5.     With lstvwXclList.ColumnHeaders
  6.         .Add , , "Activity", 4000
  7.         .Add , , "Description", 4700, lvwColumnLeft
  8.         .Add , , "Filename", 2400, lvwColumnRight
  9.     End With
  10.  
  11.     Set objListItem = lstvwXclList.ListItems.Add()
  12.     objListItem.Text = "Swimming"
  13.     objListItem.SubItems(1) = "400 m Freestyle"
  14.     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.
Sep 30 '08 #1
10 10304
NeoPa
32,556 Expert Mod 16PB
What types of objects are you using? A ListBox control on a Form?
Sep 30 '08 #2
ADezii
8,834 Expert 8TB
Juast subscribing for now. Is all the data for the ListView Control going to be Manually or Dynamically added, and if Dynamically, what is the Data Source?
Sep 30 '08 #3
NeoPa
32,556 Expert Mod 16PB
Right, so there is a ListView control available. I found it after hunting through the Additional Controls list. This would be found on a Form object for anyone who is not familiar with all the various objects available within Additional Controls.

As this is not something I'm familiar with I will simply watch with interest.
Sep 30 '08 #4
ADezii
8,834 Expert 8TB
I took the liberty of revising your code, which should now work as originally intended. Let me know how you make out:
Expand|Select|Wrap|Line Numbers
  1. Dim itmX As ListItem
  2.  
  3. 'Make sure ListView control is in report view.
  4. Me![lstvwXclList].View = lvwReport
  5.  
  6. With Me![lstvwXclList]
  7.   'Add three columns (index, key, text, width, alignment, icon)
  8.   .ColumnHeaders.Add , "Activity", "Activity", 4000, lvwColumnLeft
  9.   .ColumnHeaders.Add , "Description", "Description", 4700, lvwColumnLeft
  10.   .ColumnHeaders.Add , "Filename", "Filename", 2400, lvwColumnRight
  11. End With
  12.  
  13. 'Add Activitys to column 1 (index, key, text, icon, smallicon)
  14. Set itmX = Me![lstvwXclList].ListItems.Add(1, "Swimming", "Swimming")   'C1R1
  15. ' Use the SubItemIndex to associate the SubItem with the correct
  16. ' ColumnHeader. Use the key ("Description") to specify the right
  17. ' ColumnHeader.
  18. itmX.SubItems(Me![lstvwXclList].ColumnHeaders("Description").SubItemIndex) _
  19. = "400 m Freestyle"
  20. ' Use the ColumnHeader key to associate the SubItems string
  21. ' with the correct ColumnHeader.
  22. itmX.SubItems(Me![lstvwXclList].ColumnHeaders("Filename").SubItemIndex) _
  23. = "Swimming.xls"
  24.  
  25. 'User cannot Edit Labels
  26. Me![lstvwXclList].LabelEdit = lvwManual
P.S. - If you so desire, I can also Attach the Test Database used for this Thread, just let me know.
Sep 30 '08 #5
keirnus
48
I took the liberty of revising your code, which should now work as originally intended. Let me know how you make out:
Expand|Select|Wrap|Line Numbers
  1. Dim itmX As ListItem
  2.  
  3. 'Make sure ListView control is in report view.
  4. Me![lstvwXclList].View = lvwReport
  5.  
  6. With Me![lstvwXclList]
  7.   'Add three columns (index, key, text, width, alignment, icon)
  8.   .ColumnHeaders.Add , "Activity", "Activity", 4000, lvwColumnLeft
  9.   .ColumnHeaders.Add , "Description", "Description", 4700, lvwColumnLeft
  10.   .ColumnHeaders.Add , "Filename", "Filename", 2400, lvwColumnRight
  11. End With
  12.  
  13. 'Add Activitys to column 1 (index, key, text, icon, smallicon)
  14. Set itmX = Me![lstvwXclList].ListItems.Add(1, "Swimming", "Swimming")   'C1R1
  15. ' Use the SubItemIndex to associate the SubItem with the correct
  16. ' ColumnHeader. Use the key ("Description") to specify the right
  17. ' ColumnHeader.
  18. itmX.SubItems(Me![lstvwXclList].ColumnHeaders("Description").SubItemIndex) _
  19. = "400 m Freestyle"
  20. ' Use the ColumnHeader key to associate the SubItems string
  21. ' with the correct ColumnHeader.
  22. itmX.SubItems(Me![lstvwXclList].ColumnHeaders("Filename").SubItemIndex) _
  23. = "Swimming.xls"
  24.  
  25. 'User cannot Edit Labels
  26. Me![lstvwXclList].LabelEdit = lvwManual
P.S. - If you so desire, I can also Attach the Test Database used for this Thread, just let me know.
Sorry...it took me so long to reply.

This is what makes it work:

Me![lstvwXclList].LabelEdit = lvwManual

Now, it is un-editable. =)

Changing the LabelEdit property in VB Editor seems
to be not working. No matter what value I set, it always
reverts to its original value. (Could it be a bug?)

Anyway, this issue is considered SOLVED.

Thanks to NeoPa and ADezii!
(...for their time and effort)

You both did help another one here. =D
Oct 1 '08 #6
keirnus
48
....

Changing the LabelEdit property in VB Editor seems
to be not working. No matter what value I set, it always
reverts to its original value. (Could it be a bug?)

....
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.

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



No wonder why my settings were not reflected.

Weirdness of the ListView Property Setting solved.

(Signing off)
Oct 1 '08 #7
ADezii
8,834 Expert 8TB
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.

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



No wonder why my settings were not reflected.

Weirdness of the ListView Property Setting solved.

(Signing off)
ListViewCtrl is the ActiveX Control's OLE Class Name, you should still be able to modify the LabelEdit Property programmatically in the manner in which I have described, and what I have been successful doing. Oh well, as long as it works it will have to remain a mystery - ActiveX Controls are funny that way! (LOL)!
Oct 1 '08 #8
NeoPa
32,556 Expert Mod 16PB
Keirnus, you're welcome to what little assistance I was able to provide on this one.

May I also say that we appreciate your updating the thread with your new understanding of the matter. I expect this will be quite useful for those coming after us :)
Oct 1 '08 #9
keirnus
48
ListViewCtrl is the ActiveX Control's OLE Class Name, you should still be able to modify the LabelEdit Property programmatically in the manner in which I have described, and what I have been successful doing. Oh well, as long as it works it will have to remain a mystery - ActiveX Controls are funny that way! (LOL)!
Yes, it can be modified programatically.
It is what I am implementing now.
That's to make sure it has the right property setting
even if somebody's gonna change it in VB Editor.
Oct 3 '08 #10
ADezii
8,834 Expert 8TB
Yes, it can be modified programatically.
It is what I am implementing now.
That's to make sure it has the right property setting
even if somebody's gonna change it in VB Editor.
You can also Password Protect the code in the VB Editor Window if you so desire.
Oct 3 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Agathe | last post by:
Bonjour, Je souhaite insérer dans une table MySQL des données provenant d'un fichier texte grâce à un script PHP. Mon fichier porte l'extension "txt" et les données sont séparées par des ";'. ...
6
by: Raymond H. | last post by:
Bonjour, Je n'arrive pas à savoir comment lire via vb4 l'adresse d'un favoris dans le dossier des favoris où Internet Explorer place ses favoris. Par exemple, comment fait-on pour afficher l'url...
2
by: Mauro | last post by:
Ciao a tutti! vorrei sapere se qualcuno potrebbe darmi qualche dritta (o se sa dove reperire un tutorial) su come realizzare un trial a tempo, da integrare ad un mio programma per impedirne...
1
by: richard | last post by:
bonjour je me connecte à une base de données interbase/firebird en utilisant, KinterbasDB http://kinterbasdb.sourceforge.net/ pour ceux que ca interesse mais je pense que le probleme est le...
3
by: pascal Joseph | last post by:
J'ai un formulaire avec un seul champ text appelé "unite" et un bouton. En javascript j'aimerai utiliser un script qui interdise les valeurs de type "char" et soit supérieur à 0 J'ai trouvé...
5
by: Chris | last post by:
Bonjour, Plusieurs fichiers PHP d'un programme open source de compteur de visites viennent de se faire hacker sur mon serveur (hébergement mutualisé chez un fournisseur d'accès). Le hacker a...
3
by: Jorge Gallardo | last post by:
Hola de nuevo a todos... Agradecido a todos los que me habeis solucionado problemas anteriores... Pero como no es novedad, me surge otro. Recientemente buscando, adquiri un codigo para juntar...
1
by: Alex | last post by:
Ciao a tutti, sto sviluppando un applicazione windows, in breve all'interno dello stesso namespace ho un form con una datagrid e un thread che effettua dei controlli e "dovrebbe" caricare i dati...
15
by: Ciudad Tecnópolis | last post by:
Hola, primero que todo mil disculpas por postear una pregunta no relacionada al tema pero se que será muy útil para todos! Actualmente estoy presentando un desarrollo en .NET para una compañía y...
3
by: nano9 | last post by:
Hola gente quisiera que alguien me pudiera ayudar con un problemilla que tengo, resulta que estoy programando en ASP con C# y estoy usando un cadbgrid que se comporta parecido a un datagrid o...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.