Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default Userform Listbox subcategories?

Hi,
I was wondering if there was a way to make a value in a listbox - not
selectable.

Example. I have 2 types of forms--Property Coverage, Liability Coverage
I want my Listbox to look like this (the [ ] are the checkboxes that I
enabled in Listbox.ListStyle fmListStyleOption)

Property Coverage----
[ ] Form #PC001
[ ] Form #PC002
[ ] Form #PC003
Liability Coverage----
[ ] Form #LC001
[ ] Form #LC002
[ ] Form #LC003

Of course the list items "Property Coverage---" and "Liability Coverage----"
are just category dividers, and should not be selected (nor should it have a
checkbox next to it either). I have seen some web sites that have this; and
when users click on the categories, all sub-items are added, but I do not
want to enable this option for my users (I want them to make sure they know
exactly which forms they're selecting, and not blindly selecting all).

I'm also incorporating a 2nd Listbox, and passing the selected values over
to the 2nd Listbox (this is common seen in forms with 4 buttons that
represent MoveItemLeft, MoveAllLeft, MoveItemRight, MoveAllRight), in case
this information is needed.

Please help as soon as possible.

Thank you in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Userform Listbox subcategories?

I think the best you can do is to uncheck the box after it's been selected. And
that won't help if you're moving the selected items to a different listbox.

This is the way I'd uncheck the item:

Option Explicit
Dim BlkProc
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub ListBox1_Change()
Dim iCtr As Long

If BlkProc = True Then
Exit Sub
End If

With Me.ListBox1
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
If Right(.List(iCtr), 4) = "----" Then
'unselect it
'stop looking for changes
BlkProc = True
.Selected(iCtr) = False
'start looking for changes
BlkProc = False
End If
End If
Next iCtr
End With
End Sub

Private Sub UserForm_Initialize()
With Me.ListBox1
.ListStyle = fmListStyleOption
.MultiSelect = fmMultiSelectMulti
.AddItem "Property Coverage----"
.AddItem " Form #PC001"
.AddItem " Form #PC002"
.AddItem " Form #PC003"
.AddItem "Liability Coverage----"
.AddItem " Form #LC001"
.AddItem " Form #LC002"
.AddItem " Form #LC003"
End With
End Sub


I'm not sure how you're going to handle the moveitemright and moveitemleft,
though.

Susan wrote:

Hi,
I was wondering if there was a way to make a value in a listbox - not
selectable.

Example. I have 2 types of forms--Property Coverage, Liability Coverage
I want my Listbox to look like this (the [ ] are the checkboxes that I
enabled in Listbox.ListStyle fmListStyleOption)

Property Coverage----
[ ] Form #PC001
[ ] Form #PC002
[ ] Form #PC003
Liability Coverage----
[ ] Form #LC001
[ ] Form #LC002
[ ] Form #LC003

Of course the list items "Property Coverage---" and "Liability Coverage----"
are just category dividers, and should not be selected (nor should it have a
checkbox next to it either). I have seen some web sites that have this; and
when users click on the categories, all sub-items are added, but I do not
want to enable this option for my users (I want them to make sure they know
exactly which forms they're selecting, and not blindly selecting all).

I'm also incorporating a 2nd Listbox, and passing the selected values over
to the 2nd Listbox (this is common seen in forms with 4 buttons that
represent MoveItemLeft, MoveAllLeft, MoveItemRight, MoveAllRight), in case
this information is needed.

Please help as soon as possible.

Thank you in advance!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default Userform Listbox subcategories?

Thanks a bunch for the unselecting idea! I didn't think of it at all. I'll
play around with that then. This means that I will not be able to use the
checkbox property for my list items since the categories will have it too
(when users see a checkbox, they're going to want to click it!). And you're
also right about the moveitemleft and moveitemright. The only idea I have
right now is to take in the selected values into a hidden worksheet, and then
feed only the items without the "----" into ListBox2.

But again, thanks for the hint! Cheers!

"Dave Peterson" wrote:

I think the best you can do is to uncheck the box after it's been selected. And
that won't help if you're moving the selected items to a different listbox.

This is the way I'd uncheck the item:

Option Explicit
Dim BlkProc
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub ListBox1_Change()
Dim iCtr As Long

If BlkProc = True Then
Exit Sub
End If

With Me.ListBox1
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
If Right(.List(iCtr), 4) = "----" Then
'unselect it
'stop looking for changes
BlkProc = True
.Selected(iCtr) = False
'start looking for changes
BlkProc = False
End If
End If
Next iCtr
End With
End Sub

Private Sub UserForm_Initialize()
With Me.ListBox1
.ListStyle = fmListStyleOption
.MultiSelect = fmMultiSelectMulti
.AddItem "Property Coverage----"
.AddItem " Form #PC001"
.AddItem " Form #PC002"
.AddItem " Form #PC003"
.AddItem "Liability Coverage----"
.AddItem " Form #LC001"
.AddItem " Form #LC002"
.AddItem " Form #LC003"
End With
End Sub


I'm not sure how you're going to handle the moveitemright and moveitemleft,
though.

Susan wrote:

Hi,
I was wondering if there was a way to make a value in a listbox - not
selectable.

Example. I have 2 types of forms--Property Coverage, Liability Coverage
I want my Listbox to look like this (the [ ] are the checkboxes that I
enabled in Listbox.ListStyle fmListStyleOption)

Property Coverage----
[ ] Form #PC001
[ ] Form #PC002
[ ] Form #PC003
Liability Coverage----
[ ] Form #LC001
[ ] Form #LC002
[ ] Form #LC003

Of course the list items "Property Coverage---" and "Liability Coverage----"
are just category dividers, and should not be selected (nor should it have a
checkbox next to it either). I have seen some web sites that have this; and
when users click on the categories, all sub-items are added, but I do not
want to enable this option for my users (I want them to make sure they know
exactly which forms they're selecting, and not blindly selecting all).

I'm also incorporating a 2nd Listbox, and passing the selected values over
to the 2nd Listbox (this is common seen in forms with 4 buttons that
represent MoveItemLeft, MoveAllLeft, MoveItemRight, MoveAllRight), in case
this information is needed.

Please help as soon as possible.

Thank you in advance!


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
fill userform textbox from userform listbox clik event GregJG[_21_] Excel Programming 3 December 7th 08 04:47 PM
How do I hide subcategories in Excel? Nicole Excel Worksheet Functions 1 April 1st 08 08:00 AM
Listbox 01 -- 50 in UserForm RyanH Excel Programming 5 February 28th 08 02:34 PM
userform listbox cannot get listbox.value to transfer back to main sub [email protected] Excel Programming 1 May 17th 06 09:44 PM
Switching Subcategories into Categories and Vice Versa [email protected] Excel Worksheet Functions 7 April 17th 06 03:23 PM


All times are GMT +1. The time now is 06:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"