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

smtazulislam

Member
Local time
Today, 06:58
Joined
Mar 27, 2020
Messages
806
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:58
Joined
May 7, 2009
Messages
19,245
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:

smtazulislam

Member
Local time
Today, 06:58
Joined
Mar 27, 2020
Messages
806
if you want it to resize (height) same as the height of each element in the listbox, you will
need to code that.
Thank you very much @arnelgp
if you fixed this, lots of time save.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:58
Joined
May 7, 2009
Messages
19,245
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
 

smtazulislam

Member
Local time
Today, 06:58
Joined
Mar 27, 2020
Messages
806
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: 81

smtazulislam

Member
Local time
Today, 06:58
Joined
Mar 27, 2020
Messages
806
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:58
Joined
May 7, 2009
Messages
19,245
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.
 

Ihk

Member
Local time
Today, 05:58
Joined
Apr 7, 2020
Messages
280
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:

CJ_London

Super Moderator
Staff member
Local time
Today, 04:58
Joined
Feb 19, 2013
Messages
16,616
Only buttons have caption and picture.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 23:58
Joined
May 21, 2018
Messages
8,529
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

Ihk

Member
Local time
Today, 05:58
Joined
Apr 7, 2020
Messages
280
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

Top Bottom