Solved Resizeable column width in listbox in access (1 Viewer)

there is one more, this time there are Labels on top of the listbox which you can resize.
completely no API.
This good the HEADER mockup. A little problem there, If customized label size by increased or Decreased then its not fixed same size when the form is reopen.
 
If customized label size by increased or Decreased then its not fixed same size when the form is reopen.
i did not include any code to re-size (the height) of the label or re-size the font.
i leave it free for the user choice.

if you can notice on the Label class, i wanted to make the forecolor and the backcolor of the
label same as that with the listbox, but i opt to comment that out. i wanted for the
user to have control of what appears on the label control.

if you want it to resize (height) same as the height of each element in the listbox, you will
need to code that.

to be sure to have All labels have the same height,
on design view you select all the labels and on the Ribbon->Arrange->Size/Space->To Tallest.
 
Last edited:
you can make the 3 labels i am using on the demo db
to have Same Height. you add code on the Load event
of the Form, before putting them in collection

Code:
Private Sub Form_Load()
Dim lngMaxHeight As Long
' determine the Tallest label
lngMaxHeight = Me.Label1.Height
If Me.Label2.Height > lngMaxHeight Then
    lngMaxHeight = Me.Label2.Height
End If
If Me.Label3.Height > lngMaxHeight Then
    lngMaxHeight = Me.Label3.Height
End If
' make all the labels, have Same Height
Me.Label1.Height = lngMaxHeight
Me.Label2.Height = lngMaxHeight
Me.Label3.Height = lngMaxHeight
Set e = New ClsResizeColumn
With e
    .SetUp Me.List0, Me.Label1, Me.Label2, 1
    .SetUp Me.List0, Me.Label2, Me.Label3, 2
    .SetUp Me.List0, Me.Label3, Nothing, 3
End With
End Sub
 
you can make the 3 labels i am using on the demo db
to have Same Height. you add code on the Load event
of the Form, before putting them in collection

Code:
Private Sub Form_Load()
Dim lngMaxHeight As Long
' determine the Tallest label
lngMaxHeight = Me.Label1.Height
If Me.Label2.Height > lngMaxHeight Then
    lngMaxHeight = Me.Label2.Height
End If
If Me.Label3.Height > lngMaxHeight Then
    lngMaxHeight = Me.Label3.Height
End If
' make all the labels, have Same Height
Me.Label1.Height = lngMaxHeight
Me.Label2.Height = lngMaxHeight
Me.Label3.Height = lngMaxHeight
Set e = New ClsResizeColumn
With e
    .SetUp Me.List0, Me.Label1, Me.Label2, 1
    .SetUp Me.List0, Me.Label2, Me.Label3, 2
    .SetUp Me.List0, Me.Label3, Nothing, 3
End With
End Sub
is it Height OR width ?
I tried with Height and width.
Not fix it.
See the image
 

Attachments

  • Untitled-2.jpg
    Untitled-2.jpg
    392.7 KB · Views: 126
My idea you have do something like that

Code:
Me.List1.Height = " " ' No sense how to change this numbers
Me.List1.Width = "1;1;1"  ' No sense how to change this numbers
Me.List1.RowSourceType = "Table/Query"
Me.List1.RowSource = "table1"
Me.List1.ColumnCount = ""  ' ' No sense how to change this numbers
 
if you want to Save the "last size" of each columns of the listbox,, you save it in table.
and get the size from the table when you re-open the form.

or you need to Save the form for the changes to take effect.

that is Beyond the scope my example.
the sample is but a demonstration that you can Resize the listbox column. Nothing more.
 
there is one more, this time there are Labels on top of the listbox which you can resize.
completely no API.
With respect to above db -
Any idea how we can add pictures (icons) to labels, because normally for button, I do add pictures from properties, (picture type shared),
This way, I do sort listbox by click on heading and show picture up and down as per ASC or DESC,
For example, Arrow Up, Arrow down in this picture.
up.png
down.png

But in labels, I could not find the way to have shared picture. thank you.
 
Last edited:
then in this case is there way, to change the module / function for buttons instead of labels. I am referring to post#20, demo db by @arnelgp
Yes, but it would take a fair bit of work. You have to build a clsButton exactly like clsLabel. Then modify the clsResizeColumn to work with the new clsButton. Basically everywhere that these modules reference a label you need to reference a command button.
 
  • Love
Reactions: Ihk
Yes, but it would take a fair bit of work. You have to build a clsButton exactly like clsLabel. Then modify the clsResizeColumn to work with the new clsButton. Basically everywhere that these modules reference a label you need to reference a command button.
Thank you very much @arnelgp and @MajP . It has worked, Actually I had already tried but did not know for the button I have to write "CommandButton" instead of "button" only. :D
Regards,
 

Users who are viewing this thread

Back
Top Bottom