datagridview event firing

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
jvierra
Posts: 14614
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: datagridview event firing

Post by jvierra »

Sorry but your code makes no sense. You cannot name a column as a Boolean. A column must have a name and a value.

Code: Select all

$users = Get-AdUser -Filter { Surname -like $searchString } -SearchBase "OU=xxx,DC=xxx,DC=xxx,DC=xxx,DC=xxx" | 
    Select-Object @{n='Check';e={$false}},GivenName, Surname
$datagridview1.DataSource = [System.Collections.ArrayList]$users

User avatar
IanUoY
Posts: 88
Joined: Wed Jul 31, 2013 2:09 am

Re: datagridview event firing

Post by IanUoY »

The $false was my way of not applying anything to that column and setting it to unchecked as it is a checkbox.

I'll check your code.

(Incidentally, if I did use buttons, is they a way of setting the text of the an individual button in the grid?)

User avatar
IanUoY
Posts: 88
Joined: Wed Jul 31, 2013 2:09 am

Re: datagridview event firing

Post by IanUoY »

Ok, your code I get now.
However, it appends columns to my existing datagridview. How to I place selected rows into the existing design. Also, can I add GivenName and Surname to create one column via the select method?
Do you have any videos, etc with regard to the datagridview and how to best use?
Thanks
Ian

jvierra
Posts: 14614
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: datagridview event firing

Post by jvierra »

Don't define any columns. The grid will auto-create the columns correctly.

User avatar
IanUoY
Posts: 88
Joined: Wed Jul 31, 2013 2:09 am

Re: datagridview event firing

Post by IanUoY »

ok thanks but how do I add two selected columns together?

jvierra
Posts: 14614
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: datagridview event firing

Post by jvierra »

What does that mean? Columns are not added together.

Are you trying to concatenate two properties into one column?

Code: Select all

$users = Get-AdUser -Properties GivenName,SurName -Filter { Surname -like $searchString } -SearchBase "OU=xxx,DC=xxx,DC=xxx,DC=xxx,DC=xxx" | 
    Select-Object @{n='Check';e={$false}},@{n='Name';e={$_.GivenName+' '+$_.Surname}},SamAccountName
$datagridview1.DataSource = [System.Collections.ArrayList]$users
Before trying to work with something as complex as Forms you should take the time to learn PowerShell. It will save you a lot of time and frustration.

Windows PowerShell™ 4: TFM

Locked