Forms in PowerShell: clear checkedlistbox items when "select all" is deselected

Hello all,
I recently got help to add a "select all" checkbox to my checkedlistbox, and it works great. However, I'd like to have it also work where, when the "select all" checkbox is consequently unchecked, it clears all the checkboxes. Is this
easy to do, or would it be easier to just have an "unselect all" checkbox? Code is as follows:
[void][system.reflection.assembly]::LoadWithPartialName("System.Drawing")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Test"
$objForm.Size = New-Object System.Drawing.Size(700,300)
$objForm.StartPosition = "CenterScreen"
$CheckedListBox = New-Object System.Windows.Forms.CheckedListBox
$CheckedListBox.Location = New-Object System.Drawing.Size(20,20)
$CheckedListBox.size = New-Object System.Drawing.Size(300,100)
$CheckedListBox.CheckOnClick = $true
$CheckedListBox.Items.Add("Select All") > $null
$CheckedListBox.Items.AddRange(1..20)
$CheckedListBox.ClearSelected()
$CheckedListBox.Add_click({
If($this.selecteditem -eq 'Select All'){
For($i=1;$i -lt $CheckedListBox.Items.Count; $i++){
$CheckedListBox.SetItemChecked($i,$true)
$objForm.Controls.Add($CheckedListBox)
$Form = $objForm.ShowDialog()

Rhys,
Can you explain the $checkedlistbox.checkeditems[0] part? are you looking at the first item in the checkedlistbox object, or what is the .checkeditems[0] part referring to?
Boe,
Is this also what your code is referring to when you say $this.getitemcheckstate(0) ?
The [0] refers to the first item in the listcheckedbox (which in this case is the 'Select All' item) and checks to see if it is checked or not. Rhys's example looks at the first item in the array of checked items ('Select All' would always be the first if checked
and wouldn't exist if it was unchecked).
Boe Prox
Blog |
Twitter
PoshWSUS |
PoshPAIG | PoshChat |
PoshEventUI
PowerShell Deep Dives Book

Similar Messages

  • [svn:fx-4.0.0] 13740: Don' t unconditionally clear the item renderer selected flag in the ListBase/ updateRenderer override.

    Revision: 13740
    Revision: 13740
    Author:   [email protected]
    Date:     2010-01-24 19:49:56 -0800 (Sun, 24 Jan 2010)
    Log Message:
    Don't unconditionally clear the item renderer selected flag in the ListBase/updateRenderer override.
    QE notes:
    Doc notes:
    Bugs: sdk-25203
    Reviewer: Chet
    Tests run:
    Is noteworthy for integration:
    Ticket Links:
        http://bugs.adobe.com/jira/browse/sdk-25203
    Modified Paths:
        flex/sdk/branches/4.0.0/frameworks/projects/spark/src/spark/components/supportClasses/Lis tBase.as

    To achieve the above, try the below fix:
    var buttonBar:ButtonBar = new ButtonBar();
    buttonBar.requireSelection = true;
    Hopefully this works for you . Cheers!!

  • Internal Reconciliation when Selecting all the transactions to Reconcile

    Hello Experts,
    In Internal Reconciliation when Selecting all the transactions at once to Reconcile for setting up the Aging Report. It gives an error i.e. Reconciliation amount must be less than the balance due for this transaction 47901.
    Help Required
    Thanks & Regards

    Hi Shazad,
    please check note [1318821|https://service.sap.com/sap/support/notes/1318821] & see if this is the problem.
    All the best,
    Kerstin

  • Select all and deselect all in table control

    Hi experts,
        I want to make the select all and deselect all options in my table control.
    But i can't able to do that one. Kindly suggest me how to do that one.
    one more thing, if i select some rows in the table control, and press save it should be saved in some other table. how can i implement that one.
    Waiting for ur reply.
    Regards...
    Arun.

    Hi Arun,
    In the context node that you bind to the table, set the cardinality as 0..n and selection as 0..n. In the UI element Table, set the property selectionMode as 'multi'. Then a toggle button for select/deselect all will appear automatically in your table. You can see it in the top left corner.
    For your second question, after selecting the elemets and pressing 'save', in your event handler, do a get_selected_elements( ) on your node. This will return you a set of context elements. Loop through each element and do a get_static_attributes to get the rows. Then you can append these rows to another internal table and bind it to the context. Bind your second table to this node. If the two tables are in different views, the context nodes need to be present in the component controller and mapped to the views.
    Hope this helps.
    Regards
    Nithya

  • IDVD crashes when selecting "all themes"

    I just got ilife and this is very strange:
    When I select "all themes" (default is 6.0) iDVD just closes (in both normal and widescreen)
    However if I select any X.0 theme individually it is ok, so I can select 5.0 themes, 4.0, etc... but when I select all themes it crashes...
    Any ideas?

    Do you have and third-party themes? You might try removing them and/or see if the maker has updates if needed for iDVD6.
    I'd also delete the iDVD preference file (com.apple.iDVD.plist) and clear caches.
    Finally the makers of DVDThemePAK have found that duplicate fonts can cause issues . So you might want to read this thread too:
    http://discussions.apple.com/message.jspa?messageID=1610170#1610170
    John B

  • • INDD crash when select "all unused swatches"

    Hello -
    I think all is in the topic title…
    My InDesign® CS5 (7.0.4) crash when I select "all unused swatches" (from swatches palette).
    This happens in opened document, but also in a new empty document.
    • I delete (an rebuild) the préférences of the software.
    • I repaired the authorizations of the Mac
    Does someone know why?
    Thank you, have a nice day…
    - Dimitri
    [link removed by moderator]

    Hello Peter -
    Thank you for your answer.
    But I didn't trash manually the prefs. files.
    I did it via the keyboard keys combination (when InDesign® is launched).
    So is there another trick?
    Thank you, have a nice day…
    - Dimitri

  • Highlight table control rows when select all button is clicked

    Hi Experts,
    I have a table control and filling up rows through user input and i have also created button such as Select All* , De-Select All, and Delete.
    Now the issue is when i am pressing the select all button all the rows are marked for deletion(internal 'X' flag is set) but the rows are not highlighted(so that user will be able to know that all rows are selected).
    Anything that i am missing, please guide......
    Regards,
    Abhijit G. Borkar

    Ohh sorry there was some problem with the internet connect, that's why  this duplicate happened.
    Regards,
    Abhijit G. Borkar

  • Lightroom 1.1 crashes when selecting all photos in folder - CTRL + A

    Everytime I try to select all thumbnails in Library mode, using CTRL + A, lightroom crashes and the send msg to Microsoft comes up.
    MichaelM

    John,
    I don't have a count of actual imported images.
    I do know I have about 27,000 images on the drive, but they were all in PSE 3, 4, and 5, and have not all been imported into LR, until I need to view or work with them.
    The machine has 1GB of ram and my files are stored on a 300 GB partition of a 500 GB drive. My C: drive (for temp Win files has about 7 GB free. I am using XP Pro.
    The problem has been very consistent in 1.1 and never occurred in 1.0, that if I select a group of images in thumbs or filmstrip, it crashes LR.
    I will have to add up the folder counts. I can also get you the size of the database. I'm at work now so I will have to reply later in the week. I'm going to a new england photo conference/seminar in Mass. This Fri for 3 days (NECCC, http://www.neccc.org/) so I have to get all my work done.
    Thanks,
    MichaelM

  • Background image item when selected

    hello,
    i wanna make something like here: [http://img17.imageshack.us/my.php?image=bluebdxwwi.jpg]
    so when i click a text box, to insert some data, the entire row(with all items) being with light blue background.. how is it possible?
    Thanks

    Hello,
    In the Object Navigator, create a Visual Attribute with the blue background, then use it in the Current Record Attribute property of the block.
    Francois

  • Navigation to Next Item  when selecting LOV

    how is it possible to navigate to the next item (automatically) from an item which is having a LOV attached to it, after selecting item in the LOV...?
    Kris

    open the property palate of the lov and set auto skip to yes

  • Simplest method to clear an item when loading a page

    What is the simplest method to clear information contained in an item each time a page is loaded?
    Appreciate any help.

    Just set the item Source Used to Always... and Source Type to Always Null

  • Flash menu that highlights the selected item when changing page?

    Hi all,
    I'm trying to create a menu in flash that will highlight the
    current
    selected menu item when selecting a specific page.
    Example menu:
    - home
    - products
    - product 1
    - product 2
    - product 3
    - contacts
    - email
    - form
    Imagine you have a link in a page that opens the contact >
    email page.
    Is there a way to get the flash menu to highlight the
    "contacts > email"
    item when displaying this page?
    Something similar to this
    http://tinyurl.com/5c9993
    Is there an application that can do this easily?
    Thanks in advance for any idea.
    Tony

    here is a link to a rar file i just updated for ya.
    it is a flash movie and 2 web pages. showing how u can send
    variables to flash with java script.
    http://www.wholesalegranitedist.com/home/tutorials/jsquery.rar
    if you can't get this file let me know i will just post it
    here.
    you will have to change the menu depending on which variable
    u send. to flash. it can change on which page you visit;). ask more
    questions if you need to. or private message me.

  • Clearing open items - F-03

    Hello!
    How to clear open items when in tr FBL3N I see that some of the open items are  showed with status "Posted" green tick. To clear with tr. F-03 they should be in status open items - red mark. How could I turn posted items into open item status?
    With all the best,
    Merlin

    Hi
    In report FBL3N, you see a check mark.This means the Open Item Management CheckBox in that Clearing Account is not selected.
    Go to FS00 and view that clearing account and see the open item management in the control data tab.
    If the Open item management is selected then you will get red dot for open items and green dot for cleared items.
    For every Clearing Account Open item management check box will selected not for other G/L Accounts.
    If there is balance you cannot change the settings of the account.
    so create a new clearing account and transfer the balance , but here you cannot see the individual open items , you can see only balance transferred.
    If you want you have other option.DOWNLOAD the open items of the A/C to an excel file.Create a new Clearing A/C with open item management selected and UPLOAD the open items in the excel file to newly created account. you can use the program RFSEPA02 to do this but you take the help of an ABAPER.
    This will solve your problem
    Regards
    Venkat

  • Spry Accordian turns blue in IE 7 when selected.

    Hello,
    I built a spry accordion which turns blue, actually all of
    the menu items, when selected in IE 7.
    What do I need to do?
    Thanks,
    Ed

    Post a link to the page, please.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "lonewolfjujutsu" <[email protected]> wrote
    in message
    news:g5ehcp$el9$[email protected]..
    > Forget the last post. I still have the "blue box"
    problem!
    >
    > Any ideas?
    >
    > Ed

  • Function Module to select all entries in  ALV output

    Hi,
      I have an ALV report and Select ALL and Deselect ALL Buttons added to it .
      When the Select ALL button is pressed,all entries of the ALV report should be selected.
      When the Deselect ALL button is pressed,all entries of the ALV report should be deselected.
      Is there any function module to select all entries of the output and vice versa.
      Thanks in advance.
    Regards,
    Navas

    Hi Navas,
    I have written a part of the code you can use.
      TYPE-POOLS: slis.
      DATA : ls_event TYPE slis_alv_event.
    Set PF Status
      ls_event-name = slis_ev_pf_status_set .
      ls_event-form = slis_ev_pf_status_set .
      APPEND ls_event TO gt_event.
      CLEAR  ls_event.
    FORM pf_status_set USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'Z_STATUS'.
    ENDFORM  .                 "set_pf_status
    (no need for any perform. This will be called automatically).
    While calling the FM for ALV, pass the internal table gt_event in it_events parameter.
    Double click on Z_STATUS and add two buttons in Application Toolbar.
    1. Select All - Give function code name as &ALL,
    2. Deselect All - Give function code name as &SAL.
    Hope this helps.
    Thanks,
    Dawood.
    Edited by: Dawood.S.Ghasletwala on Apr 3, 2009 3:51 PM

Maybe you are looking for