Question
CheckBox dans une listebox
- Richard Lazaro
- Hors Ligne
- Membre platinium
-
Réduire
Plus d'informations
- Messages : 530
- Remerciements reçus 0
il y a 8 ans 3 mois #20239
par Richard Lazaro
Think-MS : (Get-Life).Days | %{ Learn-More }
\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein
Réponse de Richard Lazaro sur le sujet Re:CheckBox dans une listebox
Perso, je pense que j'appliquerais une certaine nomenclature sur les Checkbox et je ferais une recherche sur les objets à partir ce cela.
Puis pour chaque élément, je vais vérifier si c'est check ou pas.
Puis pour chaque élément, je vais vérifier si c'est check ou pas.
Think-MS : (Get-Life).Days | %{ Learn-More }
\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein
Connexion ou Créer un compte pour participer à la conversation.
- kevinklein
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 18
- Remerciements reçus 0
il y a 8 ans 3 mois #20241
par kevinklein
Réponse de kevinklein sur le sujet Re:CheckBox dans une listebox
Quelqu'un pourrait me donner un coup de main svp ?
Merci l'équipe
<br><br>Message édité par: kevinklein, à: 25/06/15 13:04
Merci l'équipe

Connexion ou Créer un compte pour participer à la conversation.
- kevinklein
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 18
- Remerciements reçus 0
il y a 8 ans 3 mois #20325
par kevinklein
Réponse de kevinklein sur le sujet Re:CheckBox dans une listebox
Désolé d'insister autant mais je sais vraiment pas comment faire 
Merci beaucoup

Merci beaucoup
Connexion ou Créer un compte pour participer à la conversation.
- Richard Lazaro
- Hors Ligne
- Membre platinium
-
Réduire
Plus d'informations
- Messages : 530
- Remerciements reçus 0
il y a 8 ans 3 mois #20326
par Richard Lazaro
Think-MS : (Get-Life).Days | %{ Learn-More }
\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein
Réponse de Richard Lazaro sur le sujet Re:CheckBox dans une listebox
Bonjour,
kevinklein écrit:
as tu au moins cherché ? Je me le demande car Google contient pas mal d'information ...
Tu n'as même pas la moindre chose a présenter aussi ...
Bref, voici un code qui marche. essaye de le comprendre et je répondrais à tes questions :
[code:1]
#Build the GUI
[xml]$xaml =
@\"
<Window
xmlns=\"schemas.microsoft.com/winfx/2006/xaml/presentation\"
xmlns:«»x=\"schemas.microsoft.com/winfx/2006/xaml\"
x:Name=\"Window\" Title=\"Initial Window\" WindowStartupLocation = \"CenterScreen\"
SizeToContent = \"WidthAndHeight\" ShowInTaskbar = \"True\" Background = \"lightgray\">
<StackPanel x:Name=\"Stack\">
<Button x:Name=\"ButtonAdd\" Content=\"Add Checkbox\" />
<Button x:Name=\"ButtonCheck\" Content=\"Check Checkbox\" />
</StackPanel>
</Window>
\"@
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
$Window=[Windows.Markup.XamlReader]::Load( $reader )
$Stack = $Window.FindName('Stack')
$ButtonAdd = $Window.FindName('ButtonAdd')
$ButtonCheck = $Window.FindName('ButtonCheck')
New-Variable -Name cptCheckBox -Option AllScope -Value 0 -Force
$ButtonAdd.Add_Click({
$newCheck = New-Object System.Windows.Controls.CheckBox
$newCheck.Name = \"CheckItem$cptCheckBox\"
$newCheck.Content = \"CheckItem$cptCheckBox\"
$Stack.Children.Add($newCheck)
$cptCheckBox++
})
$ButtonCheck.Add_Click({
$Stack.Children | Where-Object {$_.GetType().Name -eq 'CheckBox'} `
| ForEach-Object {
Write-Host $_.Name
}
})
$Window.Showdialog() | Out-Null[/code:1]
kevinklein écrit:
Désolé d'insister autant mais je sais vraiment pas comment faire
Merci beaucoup
as tu au moins cherché ? Je me le demande car Google contient pas mal d'information ...
Tu n'as même pas la moindre chose a présenter aussi ...
Bref, voici un code qui marche. essaye de le comprendre et je répondrais à tes questions :
[code:1]
#Build the GUI
[xml]$xaml =
@\"
<Window
xmlns=\"schemas.microsoft.com/winfx/2006/xaml/presentation\"
xmlns:«»x=\"schemas.microsoft.com/winfx/2006/xaml\"
x:Name=\"Window\" Title=\"Initial Window\" WindowStartupLocation = \"CenterScreen\"
SizeToContent = \"WidthAndHeight\" ShowInTaskbar = \"True\" Background = \"lightgray\">
<StackPanel x:Name=\"Stack\">
<Button x:Name=\"ButtonAdd\" Content=\"Add Checkbox\" />
<Button x:Name=\"ButtonCheck\" Content=\"Check Checkbox\" />
</StackPanel>
</Window>
\"@
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
$Window=[Windows.Markup.XamlReader]::Load( $reader )
$Stack = $Window.FindName('Stack')
$ButtonAdd = $Window.FindName('ButtonAdd')
$ButtonCheck = $Window.FindName('ButtonCheck')
New-Variable -Name cptCheckBox -Option AllScope -Value 0 -Force
$ButtonAdd.Add_Click({
$newCheck = New-Object System.Windows.Controls.CheckBox
$newCheck.Name = \"CheckItem$cptCheckBox\"
$newCheck.Content = \"CheckItem$cptCheckBox\"
$Stack.Children.Add($newCheck)
$cptCheckBox++
})
$ButtonCheck.Add_Click({
$Stack.Children | Where-Object {$_.GetType().Name -eq 'CheckBox'} `
| ForEach-Object {
Write-Host $_.Name
}
})
$Window.Showdialog() | Out-Null[/code:1]
Think-MS : (Get-Life).Days | %{ Learn-More }
\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein
Connexion ou Créer un compte pour participer à la conversation.
- kevinklein
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 18
- Remerciements reçus 0
il y a 8 ans 3 mois #20331
par kevinklein
Réponse de kevinklein sur le sujet Re:CheckBox dans une listebox
Richard Lazaro écrit:
Je te rassure Richard
, j'ai passé du temps sur le net à chercher mais comme il me manque les bases en powershell (syntaxe...) du coup c'est difficile pour moi de trouver
.
Pour en revenir au code, merci beaucoup
j'ai compris dans l'ensemble par contre comment peut on afficher les items où les checkbox ont été cochées??
Voici un exemple de code que je souhaite jouer, bien évidemment ça ne marche pas
[code:1]$ButtonCheck.Add_Click({
$Stack.Children | Where-Object {$_.GetType().Name -eq 'CheckBox' -And $_.GetType().Checked -eq $True } `
| ForEach-Object {
Write-Host $_.Name
}
})[/code:1]
Encore merci pour ton aide.
as tu au moins cherché ? Je me le demande car Google contient pas mal d'information ...
Tu n'as même pas la moindre chose a présenter aussi ...
Je te rassure Richard


Pour en revenir au code, merci beaucoup

Voici un exemple de code que je souhaite jouer, bien évidemment ça ne marche pas

[code:1]$ButtonCheck.Add_Click({
$Stack.Children | Where-Object {$_.GetType().Name -eq 'CheckBox' -And $_.GetType().Checked -eq $True } `
| ForEach-Object {
Write-Host $_.Name
}
})[/code:1]
Encore merci pour ton aide.
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.050 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Discussions générales
- CheckBox dans une listebox