Question
WindowsForm, Textbox & Label
- ThomasM
- Auteur du sujet
- Hors Ligne
- Nouveau membre
Réduire
Plus d'informations
- Messages : 7
- Remerciements reçus 0
il y a 7 ans 7 mois #22157
par ThomasM
Réponse de ThomasM sur le sujet Re:WindowsForm, Textbox & Label
Version plus courte;
Je rappel que j'utilise PowerShell ISE ou PowerGUI Script Editor et du windows form.
Merci pour votre aide
[code:1]
#################################################
# CONFIGURATION DE LA WINDOWS FORM
#################################################
# Chargement des Windows Form
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.forms\"«»)
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
# Creation de la form principale
$form2 = New-Object Windows.Forms.form
# Pour supprimer le bouton quitter (croix rouge)
$form2.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form2.ControlBox = $false
# Pour mettre la fenêtre en grand écran
$form2.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form2.WindowState=\"Maximized\"
# Titre
$form2.Text = \"Centre d'administration des licences O365\"
#################################################
# AJOUT DES COMPOSANTS
#################################################
# Label_1 : Champs de recherche d'un utilisateur
$label_1 = New-Object System.Windows.Forms.Label
$label_1.Size = New-Object System.Drawing.Size(350,20)
$Label_1.Location = New-Object System.Drawing.Point(10,20)
$label_1.Text = \"Veuillez entrer le nom d'utilisateur concerné :\"
# Zone de texte_1
$textbox_1 = New-Object System.Windows.Forms.TextBox
$textbox_1.Size = New-Object System.Drawing.Size(260,20)
$textbox_1.Location = New-Object System.Drawing.Point(10,40)
# Bouton Suivant
$button_suivant2 = New-Object System.Windows.Forms.Button
$button_suivant2.Text = \"Suivant\"
$button_suivant2.Size = New-Object System.Drawing.Size(110,23)
$button_suivant2.Location = New-Object System.drawing.Point(300,40)
$form2.Controls.Add($suivant2)
# Event bouton \"Suivant\"
$button_suivant2.Add_Click(
{
$Script:Texte = $TextBox_1.Text
$form2.Hide()
$form3.ShowDialog()
})
# Bouton Fermer
$button_fermer2 = New-Object System.Windows.Forms.Button
$button_fermer2.Text = \"Fermer\"
$button_fermer2.Size = New-Object System.drawing.Size(110,23)
$button_fermer2.Location = New-Object System.drawing.Point(300,220)
# Event bouton \"Fermer\"
$button_fermer2.Add_Click(
{
$form2.Close()
$form3.Close()
})
#################################################
# GESTION D'EVENEMENTS
#################################################
#################################################
# Ajout des composants a la Form
#################################################
$form2.Controls.Add($label_1)
$form2.Controls.Add($textbox_1)
$form2.Controls.Add($button_suivant2)
$form2.Controls.Add($button_fermer2)
$form2.Controls.Add($Script:Texte)
$form2.ShowDialog()
#####################################################################################
# Fin.form2
#####################################################################################
# Page 3 - Attribution ou Suppression des licences pour un ou plusieurs utilisateurs
# Début.form3
#####################################################################################
#################################################
# CONFIGURATION DE LA WINDOWS FORM
#################################################
# Chargement des Windows Form
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.forms\"«»)
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
# Creation de la form principale
$form3 = New-Object Windows.Forms.form
# Pour supprimer le bouton quitter (croix rouge)
$form3.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form3.ControlBox = $false
# Pour mettre la fenêtre en grand écran
$form3.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form3.WindowState=\"Maximized\"
# Titre
$form3.Text = \"Centre d'administration des licences O365\"
#################################################
# AJOUT DES COMPOSANTS
#################################################
# Affichage du nom d'utilisateur recherché : \"_ru\" = Recherche Unitaire
$label_ru = New-Object System.Windows.Forms.Label
$label_ru.Text = $Texte
$label_ru.Size = New-Object System.drawing.Size(160,30)
$label_ru.Location = New-Object System.drawing.Point(30,10)
$form3.Controls.Add($label_ru)
# Bouton Suivant
$button_suivant3 = New-Object System.Windows.Forms.Button
$button_suivant3.Text = \"Suivant\"
$button_suivant3.Size = New-Object System.Drawing.Size(120,40)
$button_suivant3.Location = New-Object System.drawing.Point(150,200)
# Bouton Quitter
$Button_fermer3 = New-Object System.Windows.Forms.Button
$button_fermer3.Text = \"Fermer\"
$button_fermer3.Size = New-Object System.drawing.Size(120,40)
$button_fermer3.Location = New-Object System.drawing.Point(150,250)
#################################################
# GESTION D'EVENEMENTS
#################################################
# Gestion d'événement quand on clique sur le bouton fermer
$button_fermer3.Add_Click(
{
$form3.Close()
})
# Gestion d'événement quand on clique sur le bouton suivant
$button_suivant3.Add_Click(
{
$form3.AcceptButton = $button_suivant3
})
# Ajout des composants a la Form
$form3.Controls.Add($label_ru)
$form3.Controls.Add($button_suivant3)
$form3.Controls.Add($button_fermer3)
$form3.Controls.Add($Texte)
######################################################
# Fin.form3
######################################################
[/code:1]
Je rappel que j'utilise PowerShell ISE ou PowerGUI Script Editor et du windows form.
Merci pour votre aide
[code:1]
#################################################
# CONFIGURATION DE LA WINDOWS FORM
#################################################
# Chargement des Windows Form
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.forms\"«»)
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
# Creation de la form principale
$form2 = New-Object Windows.Forms.form
# Pour supprimer le bouton quitter (croix rouge)
$form2.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form2.ControlBox = $false
# Pour mettre la fenêtre en grand écran
$form2.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form2.WindowState=\"Maximized\"
# Titre
$form2.Text = \"Centre d'administration des licences O365\"
#################################################
# AJOUT DES COMPOSANTS
#################################################
# Label_1 : Champs de recherche d'un utilisateur
$label_1 = New-Object System.Windows.Forms.Label
$label_1.Size = New-Object System.Drawing.Size(350,20)
$Label_1.Location = New-Object System.Drawing.Point(10,20)
$label_1.Text = \"Veuillez entrer le nom d'utilisateur concerné :\"
# Zone de texte_1
$textbox_1 = New-Object System.Windows.Forms.TextBox
$textbox_1.Size = New-Object System.Drawing.Size(260,20)
$textbox_1.Location = New-Object System.Drawing.Point(10,40)
# Bouton Suivant
$button_suivant2 = New-Object System.Windows.Forms.Button
$button_suivant2.Text = \"Suivant\"
$button_suivant2.Size = New-Object System.Drawing.Size(110,23)
$button_suivant2.Location = New-Object System.drawing.Point(300,40)
$form2.Controls.Add($suivant2)
# Event bouton \"Suivant\"
$button_suivant2.Add_Click(
{
$Script:Texte = $TextBox_1.Text
$form2.Hide()
$form3.ShowDialog()
})
# Bouton Fermer
$button_fermer2 = New-Object System.Windows.Forms.Button
$button_fermer2.Text = \"Fermer\"
$button_fermer2.Size = New-Object System.drawing.Size(110,23)
$button_fermer2.Location = New-Object System.drawing.Point(300,220)
# Event bouton \"Fermer\"
$button_fermer2.Add_Click(
{
$form2.Close()
$form3.Close()
})
#################################################
# GESTION D'EVENEMENTS
#################################################
#################################################
# Ajout des composants a la Form
#################################################
$form2.Controls.Add($label_1)
$form2.Controls.Add($textbox_1)
$form2.Controls.Add($button_suivant2)
$form2.Controls.Add($button_fermer2)
$form2.Controls.Add($Script:Texte)
$form2.ShowDialog()
#####################################################################################
# Fin.form2
#####################################################################################
# Page 3 - Attribution ou Suppression des licences pour un ou plusieurs utilisateurs
# Début.form3
#####################################################################################
#################################################
# CONFIGURATION DE LA WINDOWS FORM
#################################################
# Chargement des Windows Form
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.forms\"«»)
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
# Creation de la form principale
$form3 = New-Object Windows.Forms.form
# Pour supprimer le bouton quitter (croix rouge)
$form3.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form3.ControlBox = $false
# Pour mettre la fenêtre en grand écran
$form3.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form3.WindowState=\"Maximized\"
# Titre
$form3.Text = \"Centre d'administration des licences O365\"
#################################################
# AJOUT DES COMPOSANTS
#################################################
# Affichage du nom d'utilisateur recherché : \"_ru\" = Recherche Unitaire
$label_ru = New-Object System.Windows.Forms.Label
$label_ru.Text = $Texte
$label_ru.Size = New-Object System.drawing.Size(160,30)
$label_ru.Location = New-Object System.drawing.Point(30,10)
$form3.Controls.Add($label_ru)
# Bouton Suivant
$button_suivant3 = New-Object System.Windows.Forms.Button
$button_suivant3.Text = \"Suivant\"
$button_suivant3.Size = New-Object System.Drawing.Size(120,40)
$button_suivant3.Location = New-Object System.drawing.Point(150,200)
# Bouton Quitter
$Button_fermer3 = New-Object System.Windows.Forms.Button
$button_fermer3.Text = \"Fermer\"
$button_fermer3.Size = New-Object System.drawing.Size(120,40)
$button_fermer3.Location = New-Object System.drawing.Point(150,250)
#################################################
# GESTION D'EVENEMENTS
#################################################
# Gestion d'événement quand on clique sur le bouton fermer
$button_fermer3.Add_Click(
{
$form3.Close()
})
# Gestion d'événement quand on clique sur le bouton suivant
$button_suivant3.Add_Click(
{
$form3.AcceptButton = $button_suivant3
})
# Ajout des composants a la Form
$form3.Controls.Add($label_ru)
$form3.Controls.Add($button_suivant3)
$form3.Controls.Add($button_fermer3)
$form3.Controls.Add($Texte)
######################################################
# Fin.form3
######################################################
[/code:1]
Connexion ou Créer un compte pour participer à la conversation.
- ThomasM
- Auteur du sujet
- Hors Ligne
- Nouveau membre
Réduire
Plus d'informations
- Messages : 7
- Remerciements reçus 0
il y a 7 ans 7 mois #22217
par ThomasM
Réponse de ThomasM sur le sujet Re:WindowsForm, Textbox & Label
Personne n'a une petite idée ?
Connexion ou Créer un compte pour participer à la conversation.
- Philippe
- Hors Ligne
- Modérateur
Réduire
Plus d'informations
- Messages : 1778
- Remerciements reçus 21
il y a 7 ans 7 mois #22219
par Philippe
Réponse de Philippe sur le sujet Re:WindowsForm, Textbox & Label
n3wman écrit:
puisque tu utilise ISE fait un point d'arret sur cette ligne et regarde quand elle execute !!
[code:1]$label_ru.Text = $Texte[/code:1]
Si mais ...Personne n'a une petite idée ?
okÉtant débutant, je ne cherche pas à ce qu'on me donne tout cuit (même si la dernière réponse m'a fait gagner du temps ) si vous pouviez me guider de la démarche à suivre, cela serait sympa ! merci
tu a un souci sur le moment ou tu remplie ta box !Je rappel que j'utilise PowerShell ISE ou PowerGUI Script Editor et du windows form.
puisque tu utilise ISE fait un point d'arret sur cette ligne et regarde quand elle execute !!
[code:1]$label_ru.Text = $Texte[/code:1]
Connexion ou Créer un compte pour participer à la conversation.
- Laurent Dardenne
- Hors Ligne
- Modérateur
Réduire
Plus d'informations
- Messages : 6302
- Remerciements reçus 68
il y a 7 ans 7 mois #22221
par Laurent Dardenne
Tutoriels PowerShell
Réponse de Laurent Dardenne sur le sujet Re:WindowsForm, Textbox & Label
n3wman écrit:
Ici il faut débugger, c'est du temps qu'il faut.
Je ne sais pas si ton pb est dans l'enchaînement, qui fait quoi et quand.
En attendant rapido qq remarques par rapport à ton dernier code.
Une seule déclaration du chargements des assemblies.
Déclare Form3, avant Form2 (dépendance)
Renomme tes objets Form, ici tu es le seul qui sache ce qui est manipulé.
Et en modifiant ceci on a qq chose qui 'fonctionne' :
[code:1]# Event bouton \"Suivant\"
$button_suivant2.Add_Click(
{
$Script:Texte = $TextBox_1.Text
$form2.Hide()
$form3.ShowDialog()
$form2.Show()
})
# Event bouton \"Fermer\"
$button_fermer2.Add_Click(
{
$form2.Close()
})[/code:1]
Et avec ce code, je n'ai pas compris où est ton pb...<br><br>Message édité par: Laurent Dardenne, à: 7/09/16 18:11
On peut répondre rapidement à une question si on en connait la réponse.Personne n'a une petite idée ?
Ici il faut débugger, c'est du temps qu'il faut.
Je ne sais pas si ton pb est dans l'enchaînement, qui fait quoi et quand.
En attendant rapido qq remarques par rapport à ton dernier code.
Une seule déclaration du chargements des assemblies.
Déclare Form3, avant Form2 (dépendance)
Renomme tes objets Form, ici tu es le seul qui sache ce qui est manipulé.
Et en modifiant ceci on a qq chose qui 'fonctionne' :
[code:1]# Event bouton \"Suivant\"
$button_suivant2.Add_Click(
{
$Script:Texte = $TextBox_1.Text
$form2.Hide()
$form3.ShowDialog()
$form2.Show()
})
# Event bouton \"Fermer\"
$button_fermer2.Add_Click(
{
$form2.Close()
})[/code:1]
Et avec ce code, je n'ai pas compris où est ton pb...<br><br>Message édité par: Laurent Dardenne, à: 7/09/16 18:11
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- Philippe
- Hors Ligne
- Membre junior
Réduire
Plus d'informations
- Messages : 28
- Remerciements reçus 0
il y a 7 ans 5 mois #22569
par Philippe
Réponse de Philippe sur le sujet Re:WindowsForm, Textbox & Label
Bonjour,
Comme la souligné laurent, faut du temps et je reviens à peine de plusieurs semaines d'absence ^^
Powershell lit le code séquentiellement donc il ne peut pas t'afficher un form3 qui n'auras pas lu avant
dans ton $button_suivant2.Add_Click
supprime $form3.ShowDialog()
Dans ton $button_fermer2.Add_Click
supprime $form3.Close()
et apres ton $form3.Controls.Add($Texte)
tu ajoute $form3.ShowDialog()
ça devrais le faire
a+
Comme la souligné laurent, faut du temps et je reviens à peine de plusieurs semaines d'absence ^^
Powershell lit le code séquentiellement donc il ne peut pas t'afficher un form3 qui n'auras pas lu avant
dans ton $button_suivant2.Add_Click
supprime $form3.ShowDialog()
Dans ton $button_fermer2.Add_Click
supprime $form3.Close()
et apres ton $form3.Controls.Add($Texte)
tu ajoute $form3.ShowDialog()
ça devrais le faire
a+
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.072 secondes
- Vous êtes ici :
- Accueil
- forum
- PowerShell
- Entraide pour les débutants
- WindowsForm, Textbox & Label