Question
[Résolu] WinForm et le binding
- manu_l63@hotmail.com
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 5
- Remerciements reçus 0
il y a 16 ans 4 mois #5546
par manu_l63@hotmail.com
[Résolu] WinForm et le binding a été créé par manu_l63@hotmail.com
bonjour,
Je teste actuellement les forms avec powershell.
je fais un test simple:
une inputbox, et un label qui sert a faire l'echo de ce qui est mis dans l input.
Cela est genere au moment du onclick sur un bouton ok.
Comment reprendre la main apres avoir clique afin que soit pris en compte la modification du label?
Merci pour votre aide.
[code:1]
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = \"Data Entry Form\"
$objForm.Size = New-Object System.Drawing.Size(300,200)
$objForm.StartPosition = \"CenterScreen\"
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = \"OK\"
$OKButton.add_click({
$objTextBox.text = $x
})
$objForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,120)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = \"Cancel\"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = \"Please enter the information in the space below:\"
$objForm.Controls.Add($objLabel)
$objLabel1 = New-Object System.Windows.Forms.Label
$objLabel1.Location = New-Object System.Drawing.Size(10,70)
$objLabel1.Size = New-Object System.Drawing.Size(280,20)
$objLabel1.Text = $x
$objForm.Controls.Add($objLabel1)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,40)
$objTextBox.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
[/code:1]<br><br>Message édité par: Arnaud, à: 12/11/09 00:26
Je teste actuellement les forms avec powershell.
je fais un test simple:
une inputbox, et un label qui sert a faire l'echo de ce qui est mis dans l input.
Cela est genere au moment du onclick sur un bouton ok.
Comment reprendre la main apres avoir clique afin que soit pris en compte la modification du label?
Merci pour votre aide.
[code:1]
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = \"Data Entry Form\"
$objForm.Size = New-Object System.Drawing.Size(300,200)
$objForm.StartPosition = \"CenterScreen\"
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = \"OK\"
$OKButton.add_click({
$objTextBox.text = $x
})
$objForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,120)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = \"Cancel\"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = \"Please enter the information in the space below:\"
$objForm.Controls.Add($objLabel)
$objLabel1 = New-Object System.Windows.Forms.Label
$objLabel1.Location = New-Object System.Drawing.Size(10,70)
$objLabel1.Size = New-Object System.Drawing.Size(280,20)
$objLabel1.Text = $x
$objForm.Controls.Add($objLabel1)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,40)
$objTextBox.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
[/code:1]<br><br>Message édité par: Arnaud, à: 12/11/09 00:26
Connexion ou Créer un compte pour participer à la conversation.
- Laurent Dardenne
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 6311
- Remerciements reçus 68
il y a 16 ans 4 mois #5552
par Laurent Dardenne
Tutoriels PowerShell
Réponse de Laurent Dardenne sur le sujet Re:form et
Comme ceci :
[code:1]
$OKButton.add_click({
$objLabel1.Text=$objTextBox.Text
})
[/code:1]
[code:1]
$OKButton.add_click({
$objLabel1.Text=$objTextBox.Text
})
[/code:1]
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- Laurent Dardenne
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 6311
- Remerciements reçus 68
il y a 16 ans 4 mois #5553
par Laurent Dardenne
Tutoriels PowerShell
Réponse de Laurent Dardenne sur le sujet Re:form et
On peut aussi utiliser le databinding.
[code:1]
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = \"Data Entry Form\"
$objForm.Size = New-Object System.Drawing.Size(300,200)
$objForm.StartPosition = \"CenterScreen\"
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = \"OK\"
$OKButton.add_click({
Write-host $objLabel1.Text
})
$objForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,120)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = \"Cancel\"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = \"Please enter the information in the space below:\"
$objForm.Controls.Add($objLabel)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,40)
$objTextBox.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox)
$objForm.Topmost = $True
$objLabel1 = New-Object System.Windows.Forms.Label
$objLabel1.Location = New-Object System.Drawing.Size(10,70)
$objLabel1.Size = New-Object System.Drawing.Size(280,20)
$objLabel1.Text =\"\"
$objForm.Controls.Add($objLabel1)
#************* DataBinding **************
#Text est le nom des propriétés \"liées\"
$objLabel1.DataBindings.Add(\"Text\", $objTextBox, \"Text\"«»)
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
[/code:1]
Ce que tu saisis dans le textBox est directement inséré dans le champ \"Text\" du label.
[code:1]
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = \"Data Entry Form\"
$objForm.Size = New-Object System.Drawing.Size(300,200)
$objForm.StartPosition = \"CenterScreen\"
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = \"OK\"
$OKButton.add_click({
Write-host $objLabel1.Text
})
$objForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,120)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = \"Cancel\"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = \"Please enter the information in the space below:\"
$objForm.Controls.Add($objLabel)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,40)
$objTextBox.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox)
$objForm.Topmost = $True
$objLabel1 = New-Object System.Windows.Forms.Label
$objLabel1.Location = New-Object System.Drawing.Size(10,70)
$objLabel1.Size = New-Object System.Drawing.Size(280,20)
$objLabel1.Text =\"\"
$objForm.Controls.Add($objLabel1)
#************* DataBinding **************
#Text est le nom des propriétés \"liées\"
$objLabel1.DataBindings.Add(\"Text\", $objTextBox, \"Text\"«»)
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
[/code:1]
Ce que tu saisis dans le textBox est directement inséré dans le champ \"Text\" du label.
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- manu_l63@hotmail.com
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 5
- Remerciements reçus 0
il y a 16 ans 4 mois #5582
par manu_l63@hotmail.com
Réponse de manu_l63@hotmail.com sur le sujet Re:form et
Bonjour,
Merci pour le coup de main et le databinding.
Merci pour le coup de main et le databinding.
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.057 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- [Résolu] WinForm et le binding