Author Topic: Layouts and Listboxes and other L-words..  (Read 6940 times)

0 Members and 1 Guest are viewing this topic.

hardwired

  • Guest
Re: Layouts and Listboxes and other L-words..
« Reply #15 on: April 02, 2008, 08:55:43 AM »
Your select all code works fine, the way it should do, but not when i have that listbox_change event that loads the array aswell - when that code is in place, the select all code only selects the first item in the listbox, not all entries..

All i want is to have a checkbox that the user can check to select all the layouts (the listbox items) or uncheck to deselect them all..
But......i also need that code you posted for loading all the layoutnames from what has been selected in the listbox into a string array, built into the listbox_change event, so i can loop through them when it comes to performing the main structure of the program..

but the listbox_change event seems to be conflicting with the checkbox_click event and i don't see why, or indeed how to get round it..

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Layouts and Listboxes and other L-words..
« Reply #16 on: April 02, 2008, 09:07:06 AM »
Well, I don't know what to tell you unless you give me more than "it doesn't work" .. What version of AutoCAD? Where is the rest of your code?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hardwired

  • Guest
Re: Layouts and Listboxes and other L-words..
« Reply #17 on: April 02, 2008, 09:11:35 AM »
Here's the program, excuse the code mess, i will tidy my room when i'm done, lol

Try the select all check on the right...

I'm using AutoCAD 2008 btw..

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Layouts and Listboxes and other L-words..
« Reply #18 on: April 02, 2008, 10:21:39 AM »
I was able to figure out the problem with your program. You have X set as a global variable (and alot more too), thus when you click the button it changes the value of X before it finishes highlighting.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hardwired

  • Guest
Re: Layouts and Listboxes and other L-words..
« Reply #19 on: April 02, 2008, 11:03:09 AM »
That's done it, thanks Keith. Yeah i know, as i said, i do need to do some tidying up, but got the main principle for now and it works, so will do some housekeeping when i get a chance. You're a star

hardwired

  • Guest
Re: Layouts and Listboxes and other L-words..
« Reply #20 on: April 14, 2008, 04:45:24 AM »
Hi,

Thanks for all the help on this one Keith..

Got one final niggle, which can be got around but would like to iron this one out..


Code: [Select]
'Check whether any layout(s) have has been selected..
Dim Item As String
Dim SelectedRD As Boolean

Item = LayoutLIST.List(LayoutLIST.ListIndex)
SelectedRD = LayoutLIST.Selected(LayoutLIST.ListIndex)
If Not SelectedRD Then
    MsgBox "Please select one or more layouts to add the revision to..", vbExclamation, "Revision Details Editor.."
    Exit Sub
ElseIf SelectedRD Then
    'If stuff is selected then continue....
End If

If i use the Select All checkbox to select all the layouts in the list, then when i run the program its fine, but if i deselect one or more of the layouts after Selecting All (so the Select All checkbox value = true but not all items in the listbox are selected) the run the program, then it gets caught in the error trap and won't let the user continue as it must think that nothing has been picked..

Any ideas?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Layouts and Listboxes and other L-words..
« Reply #21 on: April 14, 2008, 08:18:24 AM »
Your code is flawed. You are checking the status of only a single layout before proceeding. To resolve that you need to check the status of all the layouts in the listbox before proceeding. You are already building a list of selected layouts in SelectedLayouts, so it makes sense to use that list to do the deed. To that end this should work.

Remember SelectedLayouts should be declared globally as a private variable so your values from one function can be used in another.

Code: [Select]
If UBound(SelectedLayouts) > 0 Then
    'lets do some stuff
Else
    MsgBox "Please select one or more layouts to add the revision to..", vbExclamation, "Revision Details Editor.."
    Exit Sub
End If

Also, to unselect the "Select All" check box, all you need to do is add a line at the end of the LayoutLIST_Change event to compare the UBound value of SelectedLayouts to LayoutLIST.ListCount

Code: [Select]
If LayoutLIST.ListCount = UBound(SelectedLayouts) Then
   SelectAll_CHK.Value = True
Else
   SelectAll_CHK.Value = False
End If

Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hardwired

  • Guest
Re: Layouts and Listboxes and other L-words..
« Reply #22 on: April 15, 2008, 05:05:02 AM »
That's worked it, once again again again thanks Keith, you're a star..

hardwired

  • Guest
Re: Layouts and Listboxes and other L-words..
« Reply #23 on: May 14, 2008, 06:37:07 AM »
Hi,

Right, had this one working for a while now and it works just as required, so many thanks to Keith for all his hard work and patience..

With this SELECTALL checkbox and layout listbox, which does as it says on the tin, can i get it select the inverse of whats been selected. Say i have selected all layouts (using the selectall check) then deselected the ones i don't want, so i have a random selection of layouts.....can i add another check or button to SELECT all the currently UNSELECTED layouts in the list and DESELECT all the currently SELECTED layouts in the list - ie: the inverse of the current selection (how many times do i wanna use the word 'select', lol)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Layouts and Listboxes and other L-words..
« Reply #24 on: May 14, 2008, 08:16:17 AM »
I wrote this on the fly, so it hasn't been tested ... you also may have to adjust the variable names:

Code: [Select]
For X = 0 to LayoutList.ListCount - 1
    If LayoutList.Selected(X) = True Then
        LayoutList.Selected(X) = False
    Else
        LayoutList.Selected(X) = True
    End If
Next X
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hardwired

  • Guest
Re: Layouts and Listboxes and other L-words..
« Reply #25 on: May 14, 2008, 09:51:17 AM »
spot on again Keith, much obliged :)