Question activer un bouton quand les TExtBox sont remplies

Plus d'informations
il y a 4 ans 8 mois #29075 par Riblito
Bonjour,


J'essaye en vain, d'activer un bouton si toutes les textbox sont remplies....

Pouvez vous corriger mon erreur svp ?


merci pour votre aide !

[code:1]$TBval = $TBNom.Text, $TBPre.text, $TBServ.Text

if ($TBval -eq \"\"«»)
{
$ButStart.Enabled = $false
}
else
{
$ButStart.Enabled = $true
}[/code:1]

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #29165 par Hicham Madini
Salut elemremy,

essaie comme ca:

[code:1]if ($TBNom.Text.Length -and $TBPre.Text.Length -and $TBServ.Text.Length)
{
$ButStart.Enabled = $true
}
else
{
$ButStart.Enabled = $false
}[/code:1]<br><br>Message édité par: hichammadd, à: 4/08/19 22:40

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #29175 par Riblito
Merci pour ta réponse :)

Mais le bouton reste bloqué quand même ... y'a t'il un rafraîchissement à faire ?

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #29181 par Hicham Madini
montre nous le code complet comme ca on peut tester!

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #29184 par Riblito
Sinon au lieu de passer le bouton de bloqué (grisé) à débloqué je pourrais faire un if =&gt; fonctionne else =&gt; affiche un message d'erreur. mais bon.


Voici tout se qui concerne le bouton, le code complet serait trop long :laugh: :

[code:1]# Windows form
[void][System.Reflection.Assembly]::LoadWithPartialName(\&quot;System.Windows.Forms\&quot;«»)
[void][System.Reflection.Assembly]::LoadWithPartialName(\&quot;System.Drawing\&quot;«»)

##########################################################################
# Les forms #
##########################################################################

#form start
$start = New-Object Windows.Forms.Form
$start.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$start.MaximizeBox = $false
$start.MinimizeBox = $false
$start.Text = \&quot;Test\&quot;
$start.Size = New-Object System.Drawing.Size(400,400)
$start.StartPosition = \&quot;CenterScreen\&quot;

#bouton

$ButStart = New-Object system.Windows.Forms.Button
$ButStart.text = \&quot;Envoyer\&quot;
$ButStart.Size = New-Object System.Drawing.Size(100,40)
$ButStart.location = New-Object System.Drawing.Point(280,320)

#textbox

$TBNom = New-Object system.Windows.Forms.TextBox
$TBNom.multiline = $false
$TBNom.Size = New-Object System.Drawing.Size(147,20)
$TBNom.location = New-Object System.Drawing.Point(200,80)

$TBPre = New-Object system.Windows.Forms.TextBox
$TBPre.multiline = $false
$TBPre.Size = New-Object System.Drawing.Size(147,20)
$TBPre.location = New-Object System.Drawing.Point(200,130)

$TBServ = New-Object system.Windows.Forms.TextBox
$TBServ.multiline = $false
$TBServ.Size = New-Object System.Drawing.Size(147,20)
$TBServ.location = New-Object System.Drawing.Point(200,180)

##########################################################################
# evenement de la page form #
##########################################################################


if ($TBNom.Text.Length -and $TBPre.Text.Length -and $TBServ.Text.Length)
{
$ButStart.Enabled = $true
}
else
{
$ButStart.Enabled = $false
}


$ButStart.Add_Click(
{

Code .....

})

$start.Controls.Add($ButStart)
$start.Controls.Add($TBNom)
$start.Controls.Add($TBPre)
$start.Controls.Add($TBServ)

$start.ShowDialog()[/code:1]<br><br>Message édité par: elemremy, à: 12/08/19 08:00

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #29188 par Hicham Madini
Salut,

à tester

[code:1]# Windows form
[void][System.Reflection.Assembly]::LoadWithPartialName(\&quot;System.Windows.Forms\&quot;«»)
[void][System.Reflection.Assembly]::LoadWithPartialName(\&quot;System.Drawing\&quot;«»)

##########################################################################
# Les forms #
##########################################################################

function YaDuText
{
if ($TBNom.Text.Length -ne 0 -and $TBPre.Text.Length -ne 0 -and $TBServ.Text.Length -ne 0)
{
$ButStart.Enabled = $true
}
else
{
$ButStart.Enabled = $false
}
}

#form start
$start = New-Object Windows.Forms.Form
$start.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$start.MaximizeBox = $false
$start.MinimizeBox = $false
$start.Text = \&quot;Test\&quot;
$start.Size = New-Object System.Drawing.Size(400,400)
$start.StartPosition = \&quot;CenterScreen\&quot;

#bouton

$ButStart = New-Object system.Windows.Forms.Button
$ButStart.text = \&quot;Envoyer\&quot;
$ButStart.Size = New-Object System.Drawing.Size(100,40)
$ButStart.location = New-Object System.Drawing.Point(280,320)
$ButStart.Enabled = $false
#textbox

$TBNom = New-Object system.Windows.Forms.TextBox
$TBNom.multiline = $false
$TBNom.Size = New-Object System.Drawing.Size(147,20)
$TBNom.location = New-Object System.Drawing.Point(200,80)

$TBPre = New-Object system.Windows.Forms.TextBox
$TBPre.multiline = $false
$TBPre.Size = New-Object System.Drawing.Size(147,20)
$TBPre.location = New-Object System.Drawing.Point(200,130)

$TBServ = New-Object system.Windows.Forms.TextBox
$TBServ.multiline = $false
$TBServ.Size = New-Object System.Drawing.Size(147,20)
$TBServ.location = New-Object System.Drawing.Point(200,180)

##########################################################################
# evenement de la page form #
##########################################################################



$TBNom.add_TextChanged({YaDuText})
$TBPre.add_TextChanged({YaDuText})
$TBServ.add_TextChanged({YaDuText})



$ButStart.Add_Click(
{

Code .....

})

$start.Controls.Add($ButStart)
$start.Controls.Add($TBNom)
$start.Controls.Add($TBPre)
$start.Controls.Add($TBServ)

$start.ShowDialog()[/code:1]<br><br>Message édité par: hichammadd, à: 13/08/19 23:13

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.074 secondes
Propulsé par Kunena