IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Scripts/Batch Discussion :

Panneau avec onglet et autosize [PowerShell]


Sujet :

Scripts/Batch

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éprouvé
    Profil pro
    Inscrit en
    Février 2003
    Messages
    926
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2003
    Messages : 926
    Par défaut Panneau avec onglet et autosize
    Bonjour,

    j'ai une fenêtre qui contient un panneau avec des onglets. Je voudrais que lorsque j’agrandis la fenêtre, le panneau s'agrandisse aussi. Avez-vous la formule qui permet de faire cela, svp?

    Code POWERSHELL : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    #----------------------------------------------
    function Show-tabcontrol_psf {
     
    	#----------------------------------------------
    	#region Import the Assemblies
    	#----------------------------------------------
    	[void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
    	[void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
    	[void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
    	[void][reflection.assembly]::Load('System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
    	[void][reflection.assembly]::Load('System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
    	#endregion Import Assemblies
     
    	#----------------------------------------------
    	#region Generated Form Objects
    	#----------------------------------------------
    	[System.Windows.Forms.Application]::EnableVisualStyles()
    	$form1 = New-Object 'System.Windows.Forms.Form'
    	$tabcontrol1 = New-Object 'System.Windows.Forms.TabControl'
    	$tabpage1 = New-Object 'System.Windows.Forms.TabPage'
    	$tabpage2 = New-Object 'System.Windows.Forms.TabPage'
    	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
    	#endregion Generated Form Objects
     
    	#----------------------------------------------
    	# User Generated Script
    	#----------------------------------------------
     
    	$form1_Load={
     
    	}
     
    	# --End User Generated Script--
    	#----------------------------------------------
    	#region Generated Events
    	#----------------------------------------------
     
    	$Form_StateCorrection_Load=
    	{
    		#Correct the initial state of the form to prevent the .Net maximized form issue
    		$form1.WindowState = $InitialFormWindowState
    	}
     
    	$Form_Cleanup_FormClosed=
    	{
    		#Remove all event handlers from the controls
    		try
    		{
    			$form1.remove_Load($form1_Load)
    			$form1.remove_Load($Form_StateCorrection_Load)
    			$form1.remove_FormClosed($Form_Cleanup_FormClosed)
    		}
    		catch { Out-Null  }
    	}
    	#endregion Generated Events
     
    	#----------------------------------------------
    	#region Generated Form Code
    	#----------------------------------------------
    	$form1.SuspendLayout()
    	$tabcontrol1.SuspendLayout()
    	#
    	# form1
    	#
    	$form1.Controls.Add($tabcontrol1)
    	$form1.AutoScaleDimensions = '6, 13'
    	$form1.AutoScaleMode = 'Font'
    	$form1.ClientSize = '453, 517'
    	$form1.Name = 'form1'
    	$form1.Text = 'Form'
    	$form1.add_Load($form1_Load)
    	#
    	# tabcontrol1
    	#
    	$tabcontrol1.Controls.Add($tabpage1)
    	$tabcontrol1.Controls.Add($tabpage2)
    	$tabcontrol1.Alignment = 'top'
    	$tabcontrol1.Location = '12, 12'
    	$tabcontrol1.Multiline = $True
    	$tabcontrol1.Name = 'tabcontrol1'
    	$tabcontrol1.SelectedIndex = 0
    	$tabcontrol1.Size = '429, 478'
    	$tabcontrol1.TabIndex = 0
    	#
    	# tabpage1
    	#
    	$tabpage1.Location = '42, 4'
    	$tabpage1.Name = 'tabpage1'
    	$tabpage1.Padding = '3, 3, 3, 3'
    	$tabpage1.Size = '583, 442'
    	$tabpage1.TabIndex = 0
    	$tabpage1.Text = 'tabpage1'
    	$tabpage1.UseVisualStyleBackColor = $True
    	#
    	# tabpage2
    	#
    	$tabpage2.Location = '23, 4'
    	$tabpage2.Name = 'tabpage2'
    	$tabpage2.Padding = '3, 3, 3, 3'
    	$tabpage2.Size = '602, 442'
    	$tabpage2.TabIndex = 1
    	$tabpage2.Text = 'tabpage2'
    	$tabpage2.UseVisualStyleBackColor = $True
    	#
     
     
    	#----------------------------------------------
     
    	#Save the initial state of the form
    	$InitialFormWindowState = $form1.WindowState
    	#Init the OnLoad event to correct the initial state of the form
    	$form1.add_Load($Form_StateCorrection_Load)
    	#Clean up the control events
    	$form1.add_FormClosed($Form_Cleanup_FormClosed)
    	#Show the Form
    	return $form1.ShowDialog()
     
    } #End Function
     
    #Call the form
    Show-tabcontrol_psf | Out-Null

  2. #2
    Membre éprouvé
    Profil pro
    Inscrit en
    Février 2003
    Messages
    926
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2003
    Messages : 926
    Par défaut
    J'ai mis un button à la place du TabControl et j'arrive à étirer le bouton lorsque j'agrandis la fenêtre :

    Code POWERSHELL : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    Function Button_Click()
    {
        [System.Windows.Forms.MessageBox]::Show("Hello World." , "My Dialog Box")
    }
    Function Generate-Form {
     
        Add-Type -AssemblyName System.Windows.Forms    
        Add-Type -AssemblyName System.Drawing
     
        # Build Form
        $Form = New-Object System.Windows.Forms.Form
        $Form.Text = "My Form"
        $Form.Size = New-Object System.Drawing.Size(200,200)
        $Form.StartPosition = "CenterScreen"
        $Form.Topmost = $True
     
        # Add Button
        $Button = New-Object System.Windows.Forms.Button
        $Button.Location = New-Object System.Drawing.Size(35,35)
        $Button.Size = New-Object System.Drawing.Size(120,23)
        $Button.Text = "Show Dialog Box"
        $Button.Anchor = [System.Windows.Forms.AnchorStyles]::Left -bor [System.Windows.Forms.AnchorStyles]::Right
        $Button.Anchor = [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Bottom
        $Form.Controls.Add($Button)
     
        #Add Button event 
        $Button.Add_Click({Button_Click})
     
     
        #Show the Form 
        $form.ShowDialog()| Out-Null 
     
    } #End Function 
     
    #Call the Function 
    Generate-Form

    C'est grâce à ces lignes :

    Code POWERSHELL : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $Button.Anchor = [System.Windows.Forms.AnchorStyles]::Left -bor [System.Windows.Forms.AnchorStyles]::Right
    $Button.Anchor = [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Bottom

    Ça marche aussi pour le TabControl. Mon problème maintenant est que la deuxième ligne écrase la première. Il me faut trouver comment mettre Left and Top ensemble et la question sera résolue.

  3. #3
    Membre éprouvé
    Profil pro
    Inscrit en
    Février 2003
    Messages
    926
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2003
    Messages : 926
    Par défaut
    C'est bon, j'ai trouvé la solution :

    Code POWERSHELL : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    $TabControl.Anchor = [System.Windows.Forms.AnchorStyles]::Top 
    -bor [System.Windows.Forms.AnchorStyles]::Bottom 
    -bor [System.Windows.Forms.AnchorStyles]::Left 
    -bor [System.Windows.Forms.AnchorStyles]::Right

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [CSS] Problème avec onglets
    Par jehlg dans le forum Mise en page CSS
    Réponses: 2
    Dernier message: 28/03/2006, 11h15
  2. JTabbedPane avec onglets dynamique
    Par oOoOuuhmAn dans le forum AWT/Swing
    Réponses: 2
    Dernier message: 18/03/2006, 16h23
  3. Probleme avec onglet et ChangeListener, help me
    Par Blast dans le forum AWT/Swing
    Réponses: 1
    Dernier message: 07/02/2006, 16h29
  4. [débutant]petit problème sur formulaire avec onglets
    Par Christophe93250 dans le forum Access
    Réponses: 2
    Dernier message: 06/01/2006, 10h46
  5. [W3C] CCS tabs, la navigation avec onglet.
    Par m@thieu dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 29/01/2005, 17h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo