Link to home
Start Free TrialLog in
Avatar of tina2009
tina2009

asked on

lock all columns in a listview on a userform

possible to no permit the resize of all columns in a listview in a userform?
Tks
Avatar of Brendan M
Brendan M
Flag of Australia image

have a look at the autoresizecolumns method
https://msdn.microsoft.com/en-us/library/system.windows.forms.listview.autoresizecolumns(v=vs.110).aspx

set it to ColumnHeaderAutoResizeStyle.None
Avatar of tina2009
tina2009

ASKER

but in a listview in a vba userform for excel?
Are your sure?
sorry me.
Add this to your code.

ListView1.HideColumnHeaders = True

Then create labels that contain your "header" text and position them over the listview columns..
Martin...
but i need HideColumnHeaders =false!
i need to use this event:

Private Sub ListView1_ColumnClick(ByVal ColumnHeader As _
                                  MSComctlLib.ColumnHeader)
Use Label1_Click() instead.
ASKER CERTIFIED SOLUTION
Avatar of tina2009
tina2009

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So that I can learn something, can you show me the code you found?
Martin...

but only a prob....
when exit with unload me, peraphs a few function in bas module modLockLVCols of this project, freeze a form!

perphs i need to destrioed the function in unload me statement?

note:
you can use:

(0 is the first column in listview)

Subclass Me.ListView1.hWnd, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
Lock-ListView-Columns.zip
I've used subclassing in VB6 to do exactly what you want to do, and so the first thing I tried was to use the same code in VBA but it didn't work and I couldn't find solution that did work. It's not surprising that you are still having a problem since even in VB6 (which is more robust than VBA) you can have problems if you aren't careful.

I encourage you to keep looking for a solution by Googling things like safe VBA subclassing but I don't understand why my solution won't work for you.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.