473,494 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

column width in ListBox

Hi everyone,

I have a database table with first name and last name entries. I am
using a ListBox to show these values.

Now what I want is that the columns adjust their width automatically
based on the length of the longest name. Is there some way I can do
this rather than set the width manually. Maybe there is a better
control to show these values and allow the user to select multiple
values at a time?

Any ideas or suggestions?

Cheers,
Pankaj

Nov 27 '06 #1
2 14657
de**********@gmail.com wrote:
Hi everyone,

I have a database table with first name and last name entries. I am
using a ListBox to show these values.

Now what I want is that the columns adjust their width automatically
based on the length of the longest name. Is there some way I can do
this rather than set the width manually. Maybe there is a better
control to show these values and allow the user to select multiple
values at a time?

Any ideas or suggestions?

Cheers,
Pankaj
Datasheets have the ability to resize but listbox/combobox are fixed width.

You might find something at http://www.lebans.com/. Search for Listbox
and also check out the table of contents for possible functions/classes
that will help you determine the width of the name.

Once you know the max size you'll then need to resize the columns via
VBA. Ex:
Me.ListBoxName.ColumnWidths = "0 in;0.75 in;2 in"
Me.ListBoxName.ColumnWidths = "0 cm;0.75 cm;2 cm"
You most likely will have to convert twips to inches or centimeters.

Nov 27 '06 #2
See:
http://www.lebans.com/listboxcolumnresize.htm
ListBoxColumnResize.zip is a Class that allows the user to resize the
ColumnWidths of a ListBox at Runtime.Also supports an Autosizing method for
the ColumnWidths.

Version 2.2 April 27/2002

Modified Columns AutoSizing method to work with both ListBox and Combo
controls.

Version 2.1 April 10/2002

BUG FIX! I thought I had cleaned this bug from all of my code but I missed
one instance. In Win9x this code will work 100% of the time:

If lngIC 0 Then But in WinNT or higher the GDI object handles are full
32 bit values so they can be represented by the VB as negative values. The
solution is to change the code to: If lngIC <0 Then

Version 2.0 April 9/2002

Added support for AUTOSIZING of ColumnWidths.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.

<de**********@gmail.comwrote in message
news:11**********************@45g2000cws.googlegro ups.com...
Hi everyone,

I have a database table with first name and last name entries. I am
using a ListBox to show these values.

Now what I want is that the columns adjust their width automatically
based on the length of the longest name. Is there some way I can do
this rather than set the width manually. Maybe there is a better
control to show these values and allow the user to select multiple
values at a time?

Any ideas or suggestions?

Cheers,
Pankaj

Nov 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3793
by: Nicolas Favre-Félix | last post by:
Hello, I have a little problem using Tkinter: I'd like to make a interface with 3 labels on the left, facing with 3 Entry on the right, a button below Entrys, and a Listbox under all. I could...
3
5278
by: Diane Yocom | last post by:
Has anybody ever seen or written code for ASP that would mimic Access' multi-column combo box? Specifically, I have a drop down box that lists about 100 five-digit codes. Each of these codes has...
4
2973
by: Giulio | last post by:
Hello, I have a continuous form with a combo box inside. From the combo box I can pick some values which, by the "after-update" event, change some other combo box values determined by a query....
0
2878
by: Matthew Wieder | last post by:
I have the common problem of the text for some of the items in my listbox exceeds the width of the listbox. The solution oft proposed of not setting the width and thereby having the listbox...
4
4901
by: Peter Gibbs | last post by:
I need some help with this problem. I'm using Access 2002 with XP. My problem is with a 2-column listbox. My VBA code puts text data into the listbox. The problem is that the text data...
3
5121
by: Randy Harris | last post by:
With a multiple column listbox, I'd like to be able to change the sort by allowing the user to click on a column. Is there a practical way detect in which column the user clicked? I know this...
3
2391
by: Nathan Sokalski | last post by:
I am looking to create a multi-column list that is scrollable, kind of like a ListBox control, only I need a way to align the columns of text that I will have (I would use spaces, but because the...
2
1726
by: =?Utf-8?B?Sm9uYXRoYW4=?= | last post by:
Hi I so new to vb.net that the paints still wet... I would like to load a listbox (as I would do using vba). The properties show multicolumn = true column width = 300 How do I set the...
1
3833
by: Sunny | last post by:
Hi, Does anyone knows, How to create a Multi Column Listbox & then Add Items to it Dynamically to each column. This only creates one column: <SELECT id="Select1" size="8" name="Select1"...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6873
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
7367
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
5453
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
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.