Solved Resizeable column width in listbox in access

Ihk

Member
Local time
Today, 22:51
Joined
Apr 7, 2020
Messages
280
Looking for a way to have resizeable column width in listbox or continuous form or continuous subform.
It will be exactly like datasheet columns which are expandable, though I can use that datasheet but I dont want to use filter, the way datasheet works.
I will use clickable header to sort ascending or descending.
But again I am afraid it will be a problem in listbox, if i dont use built-in header labels, then my custom headers probably will not expand with respective column of list box.

I know then the best way will be use listview instead of listbox that does everything what I want but its learning curve it difficult as well as it crashes application.
for example I want like this
Before (look at column width)
1668421126850.png

After (look at column width)
1668421181474.png


Does any one has such experience, any sample database will be perfect. Thank you
I know a very old link, which was also discussed on a thread here....
ListBoxColumnResize (lebans.com)
but unfortunately, I could not try this because version of database is very old and is not compatible with any of my system.
 
With all the versions (Leban's and mine) you will have to update the API declarations to handle 64bit.
 
  • Love
Reactions: Ihk
I have attached version created by @cheekybuddha and posted on posted on UtterAccess.com.
1)
How to tackle with headings, because inbuilt headings in listbox are not embossed like my above pictures. Therefore I use custom heading with vba clickable to have ascending Descending sort function.
In this If I add custom headings, then those will not resize.
2) compatibility with 64bit version
Thank you
 

Attachments

Yes it very nice, but it does not work on 64bit.
Stop wanting everything handed on a plate and do some of the work yourself. :(

You are always going to have this issue if you keep using 64bit Access, so may as well get used to it and start learning how to convert to 64bit.
 
you need to modify the api's to use ptrSafe and longPtr

see this file and keep it to hand for 64bit API declarations
 

Attachments

  • Love
Reactions: Ihk
With all the versions (Leban's and mine) you will have to update the API declarations to handle 64bit.

Stop wanting everything handed on a plate and do some of the work yourself. :(

You are always going to have this issue if you keep using 64bit Access, so may as well get used to it and start learning how to convert to 64bit.
you are right... and it should be the case. but...
 
you need to modify the api's to use ptrSafe and longPtr

Declare PtrSafe Function GetScrollPos Lib "user32" (ByVal hwnd As LongPtr, ByVal nBar As Long) As Long
Declare PtrSafe Function GetScrollRange Lib "user32" (ByVal hwnd As LongPtr, ByVal nBar As Long, lpMinPos As Long, lpMaxPos As Long) As Long
Declare PtrSafe Function GetFocus Lib "user32" Alias "GetFocus" () As LongPtr
thank you very much
 
Does not seem to stable for me. Just crashes.
 
1)
How to tackle with headings, because inbuilt headings in listbox are not embossed like my above pictures. Therefore I use custom heading with vba clickable to have ascending Descending sort function.
In this If I add custom headings, then those will not resize.
It's more tricky because now you are dealing with multiple objects, not just a single listbox.

What happens if you extend the size of the columns so the total width is greater than the width of the listbox?

Do you want to expand the listbox as well?

Or do you want to hide the headings which should disappear when the horizontal scrollbar appears?

Also, you need to move the headings with the scrollbar if there is one.

Suddenly it is a lot more coding. Not impossible, but you must work out exactly what you want to happen in each situation.

It is much simpler to use a datasheet - what is your problem with that method? You said something about filtering. Can you not just prevent the filtering?
 
It's more tricky because now you are dealing with multiple objects, not just a single listbox.

What happens if you extend the size of the columns so the total width is greater than the width of the listbox?

Do you want to expand the listbox as well?

Or do you want to hide the headings which should disappear when the horizontal scrollbar appears?

Also, you need to move the headings with the scrollbar if there is one.

Suddenly it is a lot more coding. Not impossible, but you must work out exactly what you want to happen in each situation.

It is much simpler to use a datasheet - what is your problem with that method? You said something about filtering. Can you not just prevent the filtering?
Yes it will be complicated, expanding of listbox etc as well, which is not required then.
Yest the best is datasheet the way they work, I like.

The only points I was wondering, that in datasheet it may not be possible.
1) Preventing of filtering
2) Header clicks to sort DESC / ASC
If these point are possible in datasheet, then it is the perfect solution.

As for continuous forms I add on click code on header of each column to sort.
Because working with datasheet is different topic (than this thread) then I should do research about this.
Thank you.
 
The only points I was wondering, that in datasheet it may not be possible.
1) Preventing of filtering
2) Header clicks to sort DESC / ASC
just set the datasheet form shortcut menu property to No
 
  • Love
Reactions: Ihk
just set the datasheet form shortcut menu property to No
But, that way you lose the ability to sort. Just set Allow Filters to No
filter.jpg
 

Attachments

Last edited:
  • Like
Reactions: Ihk
not related, but do you want a non-api, listbox column resizer.
the catch is that it has "handles" to resize the column.
i will put this on sample db section.
 

Attachments

there is one more, this time there are Labels on top of the listbox which you can resize.
completely no API.
 

Attachments

  • Love
Reactions: Ihk

Users who are viewing this thread

Back
Top Bottom