View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default listbox.Columnwidths question

open a new workbook.

Add a userform.

Useform1
textbox1 textbox2 textbox3

listbox1

put three textboxes above the listbox. Make the userform significantly
wider than the listbox

Put in the following code

Private Sub TextBox1_Change()
ListBox1.Width = CLng(TextBox1.Value)
End Sub

Private Sub TextBox2_Change()
ListBox1.ColumnWidths = Trim(TextBox2.Value) & ";" & Trim(TextBox3.Value)
End Sub

Private Sub TextBox3_Change()
ListBox1.ColumnWidths = Trim(TextBox2.Value) & ";" & Trim(TextBox3.Value)
End Sub

Private Sub UserForm_Initialize()
ListBox1.ColumnCount = 2
For i = 1 To 10
With ListBox1
.AddItem "AAAAAAAAAAAAAAAAAAAAAAAAA"
.List(.ListCount - 1, 1) = "BBBBBBBBBBBBBBBBBBBBBBBBB"
End With
Next
End Sub

Put in a width for the listbox in textbox1. Then put in a width for column
1 in textbox2 and a width for column 2 in textbox3.

play with the settings by changing the values in the textboxes.

Anyway, worked fine for me.

--
Regards,
Tom Ogilvy



Stuart wrote in message
...
The following statement does not appear to have
effect:

Private Sub frmName_Contractors_Initialize()
lbDataCode.Width = 100
lbDataCode.ColumnCount = 2
lbDataCode.ColumnWidths = "6;94"
End Sub

I've changed the overall width.....increasing it
I've narrowed column1 and widened 2.
Columnwidths are not set in the listbox object.

Why are the changes not being seen in the form,
please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.518 / Virus Database: 316 - Release Date: 11/09/2003