Hello,
I am trying to design a CheckedListBox that will import a list of computer names from a CSV and allow me to later do a "foreach" command to "mass enable" computers that have been disabled in AD. any pointers on how to accomplish this?
Thanks,
Austin
Checked List Box Import from CSV
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Checked List Box Import from CSV
Have you looked in the info center for reference on how to use controls
https://info.sapien.com/index.php/guis/gui-controls
https://info.sapien.com/index.php/guis/gui-controls
Re: Checked List Box Import from CSV
The site has a lot of helpful information, I am having a hard time specifically finding the command to import the CSV to the check list though...
Thanks,
Austin
Thanks,
Austin
Re: Checked List Box Import from CSV
I couldn't find any examples of how to use a CLB so here is a demo:
The code is simple:
I used embedded CSV but it can be imported.
The code is simple:
Code: Select all
$csvtxt = @'
Name,Status
X0011,True
X0012,False
X0013,False
X0014,True
'@
$form1_Load={
$csv = ConvertFrom-Csv $csvtxt
$checkedlistbox1.DataSource = [System.Collections.ArrayList]$csv
$checkedlistbox1.DisplayMember = 'Name'
for($i=0;$i -lt $checkedlistbox1.Items.Count;$i++){
$state = if($checkedlistbox1.Items[$i].Status -eq 'True'){$true}else{$false}
$checkedlistbox1.SetItemChecked($i,$state)
}
}
- Attachments
-
- Demo-CheckedListBoxLoad.psf
- (26.18 KiB) Downloaded 180 times
- LtMandella
- Posts: 61
- Last visit: Mon May 07, 2018 4:03 pm
Re: Checked List Box Import from CSV
@JV
You ought to scrape this site for all your "how-to" answers, examples, and demos and compile into a book.
I bet you would sell a pile of books! I would buy it! (and in any event thanks for all your continuing help...)
Lt
You ought to scrape this site for all your "how-to" answers, examples, and demos and compile into a book.
I bet you would sell a pile of books! I would buy it! (and in any event thanks for all your continuing help...)
Lt
Re: Checked List Box Import from CSV
Thanks. Great idea. Now I need to find an editor and a publisher. Of course by the time I publish five other people will have published the same thing.
A book is a big and time consuming project. I used to write technical sales documents on a Saturday afternoon that went 60 or more pages. I think it was good I had a captive audience. Always an emergency. Always a sale that had to be done in days for a project that could take years.
I do like knocking off quick demos. They require limited effort.
A book is a big and time consuming project. I used to write technical sales documents on a Saturday afternoon that went 60 or more pages. I think it was good I had a captive audience. Always an emergency. Always a sale that had to be done in days for a project that could take years.
I do like knocking off quick demos. They require limited effort.