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

Windows Forms Discussion :

[C#] La bonne utilisation des WinForms (ouverture-Fermeture)


Sujet :

Windows Forms

  1. #1
    Membre expérimenté
    Avatar de Harry
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2002
    Messages
    1 224
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 1 224
    Points : 1 331
    Points
    1 331
    Par défaut [C#] La bonne utilisation des WinForms (ouverture-Fermeture)
    Bonjour,

    J'ai vu qu'il y avais la suite d'une explication sur l'ouverture/fermeture en VB, mais le message d'origine est deja passé à la trappe.

    Je me demandais si il n'y avais pas la meme chose pour le C# quelquepart ?
    cad :
    Une explication complète de comment ouvrir et refermer les fenetres !
    Avec exemples de code etc..

    Merci,

    PS : j'ai un peu fouillé le forum et la FAQ C# sans meme trouver une explication basique.

    Attention le .NET sur PDA peut causer des chutes de cheveux

  2. #2
    Rédacteur
    Avatar de Louis-Guillaume Morand
    Homme Profil pro
    Cloud Architect
    Inscrit en
    Mars 2003
    Messages
    10 839
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Cloud Architect
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2003
    Messages : 10 839
    Points : 28 252
    Points
    28 252
    Par défaut
    .show et .showdialog pour ouvrir

    .close pour fermer (close qui appel le .dispose)


    je ne vois pas ce que tu veux savoir d'autre
    moi c'est Louis-Guillaume, ni Louis, ni Guillaume mais Louis-Guillaume et je n'aide pas ceux qui écorchent mon nom

  3. #3
    Membre expérimenté
    Avatar de Harry
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2002
    Messages
    1 224
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 1 224
    Points : 1 331
    Points
    1 331
    Par défaut
    J'ai essaye par exempple (avec une form nommé Second) Second.Show;

    Le compilateur me renvoie :
    [C# Erreur] WinForm.cs(323): Only assignment, call, increment, decrement, and new object expressions can be used as a statement

    Edit : c'est ce post qui ma fait me poser des questions sur la gestion de l'ouverture/fermeture :
    http://www.developpez.net/forums/vie...ghlight=ouvrir

    Attention le .NET sur PDA peut causer des chutes de cheveux

  4. #4
    Membre averti Avatar de Dinytro
    Profil pro
    Inscrit en
    Août 2003
    Messages
    390
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2003
    Messages : 390
    Points : 395
    Points
    395
    Par défaut
    devrait mieux fonctionner...
    Un problème sans solution est un problème mal posé. (Albert Einstein)

    Placez votre main sur un poêle une minute et ça vous semble durer une heure. Asseyez vous auprès d'une jolie fille une heure et ça vous semble durer une minute. C'est ça la relativité (Albert Einstein)

  5. #5
    Membre expérimenté
    Avatar de Harry
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2002
    Messages
    1 224
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 1 224
    Points : 1 331
    Points
    1 331
    Par défaut
    Code:
    Second.Show()
    devrait mieux fonctionner...
    Ca aussi j'ai deja essayé et l'erreur est :
    [C# Erreur] WinForm.cs(323): An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Show()'

    Attention le .NET sur PDA peut causer des chutes de cheveux

  6. #6
    Membre averti Avatar de Dinytro
    Profil pro
    Inscrit en
    Août 2003
    Messages
    390
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2003
    Messages : 390
    Points : 395
    Points
    395
    Par défaut
    Montre le code entier parce que là, tu as oublié un truc c'est certain !
    Un problème sans solution est un problème mal posé. (Albert Einstein)

    Placez votre main sur un poêle une minute et ça vous semble durer une heure. Asseyez vous auprès d'une jolie fille une heure et ça vous semble durer une minute. C'est ça la relativité (Albert Einstein)

  7. #7
    Expert éminent
    Avatar de neguib
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    3 627
    Détails du profil
    Informations personnelles :
    Âge : 63
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2005
    Messages : 3 627
    Points : 7 879
    Points
    7 879
    Pour le bien de ceux qui vous lisent, ayez à coeur le respect du forum et de ses règles

  8. #8
    Membre expérimenté
    Avatar de Harry
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2002
    Messages
    1 224
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 1 224
    Points : 1 331
    Points
    1 331
    Par défaut
    Oui, justement c'est ce que je vous demande : que faut-il faire !

    Voici le code du bouton qui sert a ouvrir la 2emem fiche

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    private void button2_Click(object sender, System.EventArgs e)
    		{
                Second.Show();
    		}
    Ben, c simple

    et au cas ou voici toute l'unité :



    Code : 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
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
     
    namespace TestCshar
    {
    	/// <summary>
    	/// Résumé de la description de WinForm.
    	/// </summary>
    	public class WinForm : System.Windows.Forms.Form
    	{
    		/// <summary>
    		/// Variable concepteur obligatoire.
    		/// </summary>
    		private System.ComponentModel.IContainer components;
    		private System.Windows.Forms.Button button1;
    		private System.Windows.Forms.Timer timer1;
    		private Borland.Data.Provider.BdpConnection bdpConnection1;
    		private Borland.Data.Provider.BdpDataAdapter bdpDataAdapter1;
    		private Borland.Data.Provider.BdpCommand bdpSelectCommand1;
    		private Borland.Data.Provider.BdpCommand bdpInsertCommand1;
    		private System.Data.DataSet dataSet1;
    		private System.Windows.Forms.DataGrid dataGrid1;
    		private System.Data.DataTable dataTable1;
    		private System.Data.DataColumn dataColumn1;
    		private System.Data.DataColumn dataColumn2;
    		private System.Data.DataColumn dataColumn3;
    		private System.Data.DataColumn dataColumn4;
    		private System.Data.DataColumn dataColumn5;
    		private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
    		private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
    		private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;
    		private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn3;
    		private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn4;
    		private System.Windows.Forms.Button button2;
     
    		public WinForm()
    		{
    			//
    			// Obligatoire pour la gestion du concepteur de Windows Form
    			//
    			InitializeComponent();
     
    			//
    			// TODO: Ajouter du code au constructeur après l'appel d'InitializeComponent
    			//
    		}
     
    		/// <summary>
    		/// Nettoyage des ressources utilisées.
    		/// </summary>
    		protected override void Dispose(bool disposing)
    		{
    			if (disposing)
    			{
    				if (components != null)
    				{
    					components.Dispose();
    				}
    			}
    			base.Dispose(disposing);
    		}
     
    		#region Code généré par le concepteur Windows Form
    		/// <summary>
    		/// Méthode obligatoire pour la gestion du concepteur - Ne modifiez pas
    		/// le contenu de cette méthode avec l'éditeur de code.
    		/// </summary>
    		private void InitializeComponent()
    		{
    			this.components = new System.ComponentModel.Container();
    			this.button1 = new System.Windows.Forms.Button();
    			this.timer1 = new System.Windows.Forms.Timer(this.components);
    			this.bdpConnection1 = new Borland.Data.Provider.BdpConnection();
    			this.bdpDataAdapter1 = new Borland.Data.Provider.BdpDataAdapter();
    			this.dataSet1 = new System.Data.DataSet();
    			this.dataTable1 = new System.Data.DataTable();
    			this.dataColumn1 = new System.Data.DataColumn();
    			this.dataColumn2 = new System.Data.DataColumn();
    			this.dataColumn3 = new System.Data.DataColumn();
    			this.dataColumn4 = new System.Data.DataColumn();
    			this.dataColumn5 = new System.Data.DataColumn();
    			this.bdpInsertCommand1 = new Borland.Data.Provider.BdpCommand();
    			this.bdpSelectCommand1 = new Borland.Data.Provider.BdpCommand();
    			this.dataGrid1 = new System.Windows.Forms.DataGrid();
    			this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
    			this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn();
    			this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn();
    			this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn();
    			this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn();
    			this.button2 = new System.Windows.Forms.Button();
    			((System.ComponentModel.ISupportInitialize)(this.bdpDataAdapter1)).BeginInit();
    			((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
    			((System.ComponentModel.ISupportInitialize)(this.dataTable1)).BeginInit();
    			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
    			this.SuspendLayout();
    			// 
    			// button1
    			// 
    			this.button1.BackColor = System.Drawing.SystemColors.ControlLightLight;
    			this.button1.Location = new System.Drawing.Point(56, 24);
    			this.button1.Name = "button1";
    			this.button1.Size = new System.Drawing.Size(96, 23);
    			this.button1.TabIndex = 0;
    			this.button1.Text = "Transparency";
    			this.button1.Click += new System.EventHandler(this.button1_Click);
    			// 
    			// timer1
    			// 
    			this.timer1.Interval = 200;
    			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
    			// 
    			// bdpConnection1
    			// 
    			this.bdpConnection1.ConnectionOptions = "charset=NONE;transaction isolation=ReadCommitted;servertype=0;dial" +  
    				"ect=3;packetsize=8192;rolename=";
    			this.bdpConnection1.ConnectionString = "assembly=FirebirdSql.Data.Bdp, Version=1.0.0.0, Culture=neutral, P" +  
    				"ublicKeyToken=c7d0a028dd9e545b;database=E:\\AlloVacances\\Data\\TEST" +  
    				".GXD;provider=Firebird;username=SYSDBA;password=masterkey";
    			// 
    			// bdpDataAdapter1
    			// 
    			this.bdpDataAdapter1.Active = true;
    			this.bdpDataAdapter1.DataSet = this.dataSet1;
    			this.bdpDataAdapter1.DataTable = this.dataTable1;
    			this.bdpDataAdapter1.InsertCommand = this.bdpInsertCommand1;
    			this.bdpDataAdapter1.SelectCommand = this.bdpSelectCommand1;
    			this.bdpDataAdapter1.StartRecord = 0;
    			this.bdpDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
    						new System.Data.Common.DataTableMapping("Table", "NEWTABLE", new System.Data.Common.DataColumnMapping[] {
    									new System.Data.Common.DataColumnMapping("IDTEST", "IDTEST"),
    									new System.Data.Common.DataColumnMapping("NOM", "NOM"),
    									new System.Data.Common.DataColumnMapping("PRENOM", "PRENOM"),
    									new System.Data.Common.DataColumnMapping("MONTANT", "MONTANT"),
    									new System.Data.Common.DataColumnMapping("VERSION", "VERSION")})});
    			// 
    			// dataSet1
    			// 
    			this.dataSet1.DataSetName = "NewDataSet";
    			this.dataSet1.Locale = new System.Globalization.CultureInfo("fr-FR");
    			this.dataSet1.Tables.AddRange(new System.Data.DataTable[] {
    						this.dataTable1});
    			// 
    			// dataTable1
    			// 
    			this.dataTable1.Columns.AddRange(new System.Data.DataColumn[] {
    						this.dataColumn1,
    						this.dataColumn2,
    						this.dataColumn3,
    						this.dataColumn4,
    						this.dataColumn5});
    			this.dataTable1.TableName = "NEWTABLE";
    			// 
    			// dataColumn1
    			// 
    			this.dataColumn1.AllowDBNull = false;
    			this.dataColumn1.ColumnName = "IDTEST";
    			this.dataColumn1.DataType = typeof(int);
    			// 
    			// dataColumn2
    			// 
    			this.dataColumn2.ColumnName = "NOM";
    			this.dataColumn2.MaxLength = 40;
    			// 
    			// dataColumn3
    			// 
    			this.dataColumn3.ColumnName = "PRENOM";
    			this.dataColumn3.MaxLength = 40;
    			// 
    			// dataColumn4
    			// 
    			this.dataColumn4.ColumnName = "MONTANT";
    			this.dataColumn4.DataType = typeof(decimal);
    			// 
    			// dataColumn5
    			// 
    			this.dataColumn5.ColumnName = "VERSION";
    			this.dataColumn5.DataType = typeof(int);
    			// 
    			// bdpInsertCommand1
    			// 
    			this.bdpInsertCommand1.CommandOptions = null;
    			this.bdpInsertCommand1.CommandText = "INSERT INTO \"NEWTABLE\" (\"IDTEST\",\"NOM\",\"PRENOM\",\"MONTANT\",\"VERSION" +  
    				"\") VALUES (?,?,?,?,?)";
    			this.bdpInsertCommand1.CommandType = System.Data.CommandType.Text;
    			this.bdpInsertCommand1.Connection = this.bdpConnection1;
    			this.bdpInsertCommand1.ParameterCount = ((short)(5));
    			this.bdpInsertCommand1.Parameters.Add(new Borland.Data.Common.BdpParameter("@p1", Borland.Data.Common.BdpType.Unknown, Borland.Data.Common.BdpType.Unknown, 4, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), 0, "IDTEST", System.Data.DataRowVersion.Current, null));
    			this.bdpInsertCommand1.Parameters.Add(new Borland.Data.Common.BdpParameter("@p2", Borland.Data.Common.BdpType.Unknown, Borland.Data.Common.BdpType.Unknown, 40, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), 0, "NOM", System.Data.DataRowVersion.Current, null));
    			this.bdpInsertCommand1.Parameters.Add(new Borland.Data.Common.BdpParameter("@p3", Borland.Data.Common.BdpType.Unknown, Borland.Data.Common.BdpType.Unknown, 40, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), 0, "PRENOM", System.Data.DataRowVersion.Current, null));
    			this.bdpInsertCommand1.Parameters.Add(new Borland.Data.Common.BdpParameter("@p4", Borland.Data.Common.BdpType.Unknown, Borland.Data.Common.BdpType.Unknown, 8, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(2)), 0, "MONTANT", System.Data.DataRowVersion.Current, null));
    			this.bdpInsertCommand1.Parameters.Add(new Borland.Data.Common.BdpParameter("@p5", Borland.Data.Common.BdpType.Unknown, Borland.Data.Common.BdpType.Unknown, 4, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), 0, "VERSION", System.Data.DataRowVersion.Current, null));
    			this.bdpInsertCommand1.SchemaName = null;
    			this.bdpInsertCommand1.Transaction = null;
    			this.bdpInsertCommand1.UpdatedRowSource = System.Data.UpdateRowSource.None;
    			// 
    			// bdpSelectCommand1
    			// 
    			this.bdpSelectCommand1.CommandOptions = null;
    			this.bdpSelectCommand1.CommandText = "SELECT * FROM NEWTABLE";
    			this.bdpSelectCommand1.CommandType = System.Data.CommandType.Text;
    			this.bdpSelectCommand1.Connection = this.bdpConnection1;
    			this.bdpSelectCommand1.ParameterCount = ((short)(0));
    			this.bdpSelectCommand1.SchemaName = null;
    			this.bdpSelectCommand1.Transaction = null;
    			this.bdpSelectCommand1.UpdatedRowSource = System.Data.UpdateRowSource.None;
    			// 
    			// dataGrid1
    			// 
    			this.dataGrid1.BackgroundColor = System.Drawing.Color.LavenderBlush;
    			this.dataGrid1.CaptionBackColor = System.Drawing.Color.FromArgb(((byte)(255)), ((byte)(224)), ((byte)(192)));
    			this.dataGrid1.DataMember = "NEWTABLE";
    			this.dataGrid1.DataSource = this.dataSet1;
    			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
    			this.dataGrid1.Location = new System.Drawing.Point(0, 80);
    			this.dataGrid1.Name = "dataGrid1";
    			this.dataGrid1.SelectionBackColor = System.Drawing.Color.FromArgb(((byte)(255)), ((byte)(255)), ((byte)(128)));
    			this.dataGrid1.Size = new System.Drawing.Size(528, 168);
    			this.dataGrid1.TabIndex = 1;
    			this.dataGrid1.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
    						this.dataGridTableStyle1});
    			// 
    			// dataGridTableStyle1
    			// 
    			this.dataGridTableStyle1.DataGrid = this.dataGrid1;
    			this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
    						this.dataGridTextBoxColumn1,
    						this.dataGridTextBoxColumn2,
    						this.dataGridTextBoxColumn3,
    						this.dataGridTextBoxColumn4});
    			this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
    			this.dataGridTableStyle1.MappingName = "";
    			this.dataGridTableStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((byte)(255)), ((byte)(192)), ((byte)(192)));
    			// 
    			// dataGridTextBoxColumn1
    			// 
    			this.dataGridTextBoxColumn1.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
    			this.dataGridTextBoxColumn1.Format = "";
    			this.dataGridTextBoxColumn1.FormatInfo = null;
    			this.dataGridTextBoxColumn1.HeaderText = "ID";
    			this.dataGridTextBoxColumn1.MappingName = "IDTEST";
    			this.dataGridTextBoxColumn1.Width = 75;
    			// 
    			// dataGridTextBoxColumn2
    			// 
    			this.dataGridTextBoxColumn2.Format = "";
    			this.dataGridTextBoxColumn2.FormatInfo = null;
    			this.dataGridTextBoxColumn2.HeaderText = "Prenom";
    			this.dataGridTextBoxColumn2.MappingName = "PRENOM";
    			this.dataGridTextBoxColumn2.Width = 75;
    			// 
    			// dataGridTextBoxColumn3
    			// 
    			this.dataGridTextBoxColumn3.Format = "";
    			this.dataGridTextBoxColumn3.FormatInfo = null;
    			this.dataGridTextBoxColumn3.HeaderText = "Nom";
    			this.dataGridTextBoxColumn3.MappingName = "NOM";
    			this.dataGridTextBoxColumn3.Width = 75;
    			// 
    			// dataGridTextBoxColumn4
    			// 
    			this.dataGridTextBoxColumn4.Format = "";
    			this.dataGridTextBoxColumn4.FormatInfo = null;
    			this.dataGridTextBoxColumn4.HeaderText = "Montant";
    			this.dataGridTextBoxColumn4.MappingName = "MONTANT";
    			this.dataGridTextBoxColumn4.Width = 75;
    			// 
    			// button2
    			// 
    			this.button2.Location = new System.Drawing.Point(336, 24);
    			this.button2.Name = "button2";
    			this.button2.TabIndex = 2;
    			this.button2.Text = "Ouvrir";
    			this.button2.Click += new System.EventHandler(this.button2_Click);
    			// 
    			// WinForm
    			// 
    			this.AutoScale = false;
    			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    			this.ClientSize = new System.Drawing.Size(544, 261);
    			this.Controls.Add(this.button2);
    			this.Controls.Add(this.dataGrid1);
    			this.Controls.Add(this.button1);
    			this.Name = "WinForm";
    			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
    			this.Text = "WinForm C# test";
    			this.TransparencyKey = System.Drawing.Color.Magenta;
    			((System.ComponentModel.ISupportInitialize)(this.bdpDataAdapter1)).EndInit();
    			((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
    			((System.ComponentModel.ISupportInitialize)(this.dataTable1)).EndInit();
    			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
    			this.ResumeLayout(false);
    		}
    		#endregion
     
    		/// <summary>
    		/// Le point d'entrée principal de l'application.
    		/// </summary>
    		[STAThread]
    		static void Main() 
    		{
    			Application.Run(new WinForm());
    		}
     
    		private void button1_Click(object sender, System.EventArgs e)
    		{
    			timer1.Enabled = true;
    		}
     
    		private void timer1_Tick(object sender, System.EventArgs e)
    		{
    			if (Opacity > 0.95)
    			{
    				Opacity = 0.05;
    			} else Opacity = Opacity + 0.05;
    		}
     
    		private void button2_Click(object sender, System.EventArgs e)
    		{
                Second.Show();
    		}
    	}
    }
    J'utilise l'environnement C# Builder intégré dans Delphi 2005.

    Attention le .NET sur PDA peut causer des chutes de cheveux

  9. #9
    Expert éminent
    Avatar de neguib
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    3 627
    Détails du profil
    Informations personnelles :
    Âge : 63
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2005
    Messages : 3 627
    Points : 7 879
    Points
    7 879
    Par défaut
    Ben je crois que "Second" n'a tout simplement pas été instancié
    Pour le bien de ceux qui vous lisent, ayez à coeur le respect du forum et de ses règles

  10. #10
    Membre expérimenté
    Avatar de Harry
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2002
    Messages
    1 224
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 1 224
    Points : 1 331
    Points
    1 331
    Par défaut
    Si j'ajoute 'this'
    [C# Erreur] WinForm.cs(323): No overload for method 'Show' takes '1' arguments
    Euh, faut faire comment pour instancier (J'ai commencé le C#.NET cet aprem après avoir scruté les FAQ etc )

    Par contre source possible de problèmes ?? : J'ai donné le meme nom a la WinForm que au fichier .cs qui va avec : L'environnement ma laisse faire donc je suppose que l'on peux le faire en C# (On peut pas en Delphi).

    Attention le .NET sur PDA peut causer des chutes de cheveux

  11. #11
    Expert éminent
    Avatar de neguib
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    3 627
    Détails du profil
    Informations personnelles :
    Âge : 63
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2005
    Messages : 3 627
    Points : 7 879
    Points
    7 879
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    private void button2_Click(object sender, System.EventArgs e) 
          { 
                MonTypeDeForm Second = new MonTypeDeForm ;
                Second.Show(); 
          }
    Pour le bien de ceux qui vous lisent, ayez à coeur le respect du forum et de ses règles

  12. #12
    Membre averti Avatar de Dinytro
    Profil pro
    Inscrit en
    Août 2003
    Messages
    390
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2003
    Messages : 390
    Points : 395
    Points
    395
    Par défaut
    Je viens rejouter un commentaire tout de même ...
    j'ai demandé à voir le code parce que je me doutais qu'il y avait un problème de déclaration avec l'erreur concernat le static ....

    Ben je crois que "Second" n'a tout simplement pas été instancié
    Non seulement c'est exact mais en plus, elle n'a pas été déclaré non plus.
    dans son code, il appelle la method Show de la classe Second et pour cela fonctionne il faudrait bien entendu que Show soit static.

    ceci explique cette erreur :
    C# Erreur] WinForm.cs(323): An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Show()'
    Un problème sans solution est un problème mal posé. (Albert Einstein)

    Placez votre main sur un poêle une minute et ça vous semble durer une heure. Asseyez vous auprès d'une jolie fille une heure et ça vous semble durer une minute. C'est ça la relativité (Albert Einstein)

  13. #13
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Points : 19 434
    Points
    19 434
    Par défaut
    Citation Envoyé par neguib
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    private void button2_Click(object sender, System.EventArgs e) 
          { 
                MonTypeDeForm Second = new MonTypeDeForm ;
                Second.Show(); 
          }
    +1: je suis du même avis que neguib

  14. #14
    Membre expérimenté
    Avatar de Harry
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2002
    Messages
    1 224
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 1 224
    Points : 1 331
    Points
    1 331
    Par défaut
    Donc l'appel de cette winForm devrait s'ecrire comme ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    private void button2_Click(object sender, System.EventArgs e)
    		{
    			WinForm Second = new WinForm;
    			Second.Show(this);
    		}
    Et en C# on fait comment pour declarer une autre Form ?
    (Il en veux pas dans le using, reconnais pas require_once, ya pas de uses et il ne semble pas y avoir d'endroits pré-établis ??)

    Attention le .NET sur PDA peut causer des chutes de cheveux

  15. #15
    Membre expérimenté
    Avatar de Mehdi Feki
    Profil pro
    Inscrit en
    Décembre 2004
    Messages
    1 113
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Décembre 2004
    Messages : 1 113
    Points : 1 566
    Points
    1 566
    Par défaut
    Il faut utiliser le nom de la classe de ta form

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    public class MaFenetre : System.Windows.Forms.Form
    	{
    //..............
    }
    pour l'afficher :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    private void button2_Click(object sender, System.EventArgs e)
          {
             MaFenetre Second = new MaFenetre() ;
             Second.Show(this);
          }
    n'oublie pas les parentheses de l'instance .

    J'espere aue c'est bien ca ton probleme[/code]
    Mehdi Feki : Modérateur .Net

  16. #16
    Membre averti Avatar de Dinytro
    Profil pro
    Inscrit en
    Août 2003
    Messages
    390
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2003
    Messages : 390
    Points : 395
    Points
    395
    Par défaut
    +1: je suis du même avis que neguib
    Tout le monde est du même avis que Neguib ... puisqu'il manquait la déclaration ET l'instanciation....neguib is the best
    Un problème sans solution est un problème mal posé. (Albert Einstein)

    Placez votre main sur un poêle une minute et ça vous semble durer une heure. Asseyez vous auprès d'une jolie fille une heure et ça vous semble durer une minute. C'est ça la relativité (Albert Einstein)

  17. #17
    Membre expérimenté
    Avatar de Harry
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2002
    Messages
    1 224
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 1 224
    Points : 1 331
    Points
    1 331
    Par défaut
    mehdi_tn je te comprend pas terrible, ca :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    public class MaFenetre : System.Windows.Forms.Form 
       { 
    //.............. 
    }
    Je le met ou ?? ca ressemble à une Winform, c'est ce que j'ai deja dans les fiches exemple dans la fiche que je veux appeler :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    public class Second : System.Windows.Forms.Form
    	{
    et après ya tout le code de la fiche...

    Ensuite pour afficher ce que j'ai fait n'est pas bon ?

    Tu me dis :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    private void button2_Click(object sender, System.EventArgs e) 
          { 
             MaFenetre Second = new MaFenetre() ; 
             Second.Show(this); 
          }
    Mais MaFenetre (que je veux appeler) s'appelle Second justement... je vois pas ou tu veux en venir ?

    Je recommence a me sentir embrouillé la

    Attention le .NET sur PDA peut causer des chutes de cheveux

  18. #18
    Membre averti Avatar de Dinytro
    Profil pro
    Inscrit en
    Août 2003
    Messages
    390
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2003
    Messages : 390
    Points : 395
    Points
    395
    Par défaut
    Et en C# on fait comment pour declarer une autre Form ?
    Que l'on soit bien d'accord : tu veux déclarer une autre form mais du même type ?

    si oui, il suffit de recopier le code de Neguib, ce n'est qu'une variable de plus, rien de bien compliqué :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    MaFenetre Second = new MaFenetre() ; 
    MaFenetre third = new MaFenetre() ;
     
    //Pour les afficher
    Second.Show(); 
    third.Show();
    est ce bien ça que tu voulais savoir ?
    Un problème sans solution est un problème mal posé. (Albert Einstein)

    Placez votre main sur un poêle une minute et ça vous semble durer une heure. Asseyez vous auprès d'une jolie fille une heure et ça vous semble durer une minute. C'est ça la relativité (Albert Einstein)

  19. #19
    Rédacteur

    Homme Profil pro
    Expert iOS
    Inscrit en
    Juin 2005
    Messages
    413
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Expert iOS

    Informations forums :
    Inscription : Juin 2005
    Messages : 413
    Points : 1 619
    Points
    1 619
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par Harry
    Mais MaFenetre (que je veux appeler) s'appelle Second justement... je vois pas ou tu veux en venir ?

    Je recommence a me sentir embrouillé la

    MaFenêtre est la type (ou le nom de la classe appel ca comme tu veux ^^ ) de la form que tu vas ouvrir, Second est le nom de l'instance de la classe

  20. #20
    Membre expérimenté
    Avatar de Harry
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2002
    Messages
    1 224
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 1 224
    Points : 1 331
    Points
    1 331
    Par défaut
    Euh, donc vu que je travaille avec des WinForms ce que j'ai mis plus haut est bon ?

    Attention le .NET sur PDA peut causer des chutes de cheveux

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. Bonne utilisation des models
    Par Kaimite dans le forum Zend Framework
    Réponses: 4
    Dernier message: 04/07/2008, 15h43
  2. [gtkmm] de la bonne utilisation des pixbuf
    Par Rniamo dans le forum GTK+
    Réponses: 2
    Dernier message: 23/06/2008, 22h56
  3. bonne utilisation des alias
    Par gok6tm dans le forum Requêtes
    Réponses: 0
    Dernier message: 15/11/2007, 11h48
  4. Avis sur la bonne utilisation des Threads
    Par Pitivier dans le forum Général Java
    Réponses: 8
    Dernier message: 28/11/2006, 20h07

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