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 :

accéder a des élément d'un classe partagé en deux (partial)


Sujet :

Windows Forms

  1. #1
    Membre régulier
    Étudiant
    Inscrit en
    Août 2008
    Messages
    349
    Détails du profil
    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2008
    Messages : 349
    Points : 93
    Points
    93
    Par défaut accéder a des élément d'un classe partagé en deux (partial)
    bonjour tout le monde,
    j'ai une classe MainForm qui est subdivisée en deux (partial) , une partie qui contient la méthode main (soit A) et une autre contient la définition des controls composant l'interface graphique (soit B), j'ai déclaré les controls public mais je ne peux acceder quaux éléments déclaré dans la partie A, alors que j'ai besoin des controls de la partie B, quelqu'un peut m'aider.

  2. #2
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Points : 39 749
    Points
    39 749
    Par défaut
    Tu as du te planter dans la déclaration de classe partielle, normalement tu peux accéder aux membres définis dans les 2 parties, comme si tout était en une seule partie...

    Fais voir la déclaration des 2 parties de ta classe

  3. #3
    Membre régulier
    Étudiant
    Inscrit en
    Août 2008
    Messages
    349
    Détails du profil
    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2008
    Messages : 349
    Points : 93
    Points
    93
    Par défaut
    voila la première partie
    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
     
     
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Windows.Forms;
    using System.IO;
    using System.Xml.Linq;
    using System.Xml.Schema;
    using System.Data;
    using System.Diagnostics;
    using System.Reflection.Emit;
    using System.ComponentModel;
    using System.Text;
    using System.Windows;
     
     
     
    namespace test
    {
    	/// <summary>
    	/// Description of MainForm.
    	/// </summary>
    	public partial class MainForm : Form
    	{
            public RichTextBox richTextBox0;
            public int indexRecherche=0;
            public ArrayList listIndex = new ArrayList();
            public int nbTab =0; // le nombre des tabpages.
            public StreamWriter objWriter;
    		[STAThread]
    		public static void Main(string[] args)
    		{
    			Application.EnableVisualStyles();
    			Application.SetCompatibleTextRenderingDefault(false);
    			Application.Run(new MainForm());
     
    		}
     
     
            public MainForm()
    		{
    			//
    			// The InitializeComponent() call is required for Windows Forms designer support.
    			//
    			InitializeComponent();
     
    			//
    			// TODO: Add constructor code after the InitializeComponent() call.
    			//
    		}
     
     
    	}
    }

    et le deuxième partie :
    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
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
     
     
    namespace test
    {
    	partial class MainForm
    	{
    		/// <summary>
    		/// Designer variable used to keep track of non-visual components.
    		/// </summary>
    		private System.ComponentModel.IContainer components = null;
     
    		/// <summary>
    		/// Disposes resources used by the form.
    		/// </summary>
    		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    		protected override void Dispose(bool disposing)
    		{
    			if (disposing) {
    				if (components != null) {
    					components.Dispose();
    				}
    			}
    			base.Dispose(disposing);
    		}
     
    		/// <summary>
    		/// This method is required for Windows Forms designer support.
    		/// Do not change the method contents inside the source code editor. The Forms designer might
    		/// not be able to load this method if it was changed manually.
    		/// </summary>
    		private void InitializeComponent()
    		{
                this.components = new System.ComponentModel.Container();
                this.menuStrip1 = new System.Windows.Forms.MenuStrip();
                this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.saveFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.insertToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.insertTagToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.verifyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.simulateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.simulateRegExToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.resultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.compareToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.compareFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.compareSectionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.indenteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.xMLTreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.findToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.configurationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.includeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.validateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.xSDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
                this.howToUseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.helpTagsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.contextMenuStrip3 = new System.Windows.Forms.ContextMenuStrip(this.components);
                this.closeToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
                this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
                this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components);
                this.closeToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
                this.enfinToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.splitContainer1 = new System.Windows.Forms.SplitContainer();
                this.treeView1 = new System.Windows.Forms.TreeView();
                this.splitContainer2 = new System.Windows.Forms.SplitContainer();
                this.tabControl1 = new System.Windows.Forms.TabControl();
                this.console = new System.Windows.Forms.RichTextBox();
                this.console.ReadOnly = true;
                this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components);
                this.menuStrip1.SuspendLayout();
                this.contextMenuStrip3.SuspendLayout();
                this.contextMenuStrip1.SuspendLayout();
                this.contextMenuStrip2.SuspendLayout();
                this.splitContainer1.Panel1.SuspendLayout();
                this.splitContainer1.Panel2.SuspendLayout();
                this.splitContainer1.SuspendLayout();
                this.splitContainer2.Panel1.SuspendLayout();
                this.splitContainer2.Panel2.SuspendLayout();
                this.splitContainer2.SuspendLayout();
                ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit();
                this.SuspendLayout();
                // 
                // menuStrip1
                // 
                this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.fileToolStripMenuItem,
                this.insertToolStripMenuItem,
                this.simulateToolStripMenuItem,
                this.compareToolStripMenuItem,
                this.helpToolStripMenuItem,
                this.validateToolStripMenuItem,
                this.helpToolStripMenuItem1});
                this.menuStrip1.Location = new System.Drawing.Point(0, 0);
                this.menuStrip1.Name = "menuStrip1";
                this.menuStrip1.Size = new System.Drawing.Size(726, 24);
                this.menuStrip1.TabIndex = 3;
                this.menuStrip1.Text = "menuStrip1";
                // 
                // fileToolStripMenuItem
                // 
                this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.newToolStripMenuItem,
                this.openToolStripMenuItem,
                this.saveToolStripMenuItem,
                this.saveFileToolStripMenuItem,
                this.exitToolStripMenuItem});
                this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
                this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20);
                this.fileToolStripMenuItem.Text = "File";
                // 
                // newToolStripMenuItem
                // 
                this.newToolStripMenuItem.Name = "newToolStripMenuItem";
                this.newToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
                this.newToolStripMenuItem.Text = "New";
                this.newToolStripMenuItem.Click += new System.EventHandler(this.NewToolStripMenuItemClick);
                // 
                // openToolStripMenuItem
                // 
                this.openToolStripMenuItem.Name = "openToolStripMenuItem";
                this.openToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
                this.openToolStripMenuItem.Text = "Open an XML file";
                this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
                // 
                // saveToolStripMenuItem
                // 
                this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
                this.saveToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
                this.saveToolStripMenuItem.Text = "Save Node";
                this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
                // 
                // saveFileToolStripMenuItem
                // 
                this.saveFileToolStripMenuItem.Name = "saveFileToolStripMenuItem";
                this.saveFileToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
                this.saveFileToolStripMenuItem.Text = "Save File";
                this.saveFileToolStripMenuItem.Click += new System.EventHandler(this.saveFileToolStripMenuItem_Click);
                // 
                // exitToolStripMenuItem
                // 
                this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
                this.exitToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
                this.exitToolStripMenuItem.Text = "Exit";
                this.exitToolStripMenuItem.Click += new System.EventHandler(this.ExitToolStripMenuItemClick);
                // 
                // insertToolStripMenuItem
                // 
                this.insertToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.insertTagToolStripMenuItem,
                this.verifyToolStripMenuItem});
                this.insertToolStripMenuItem.Name = "insertToolStripMenuItem";
                this.insertToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
                this.insertToolStripMenuItem.Text = "Insert";
                // 
                // insertTagToolStripMenuItem
                // 
                this.insertTagToolStripMenuItem.Name = "insertTagToolStripMenuItem";
                this.insertTagToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
                this.insertTagToolStripMenuItem.Text = "Insert Tag";
                // 
                // verifyToolStripMenuItem
                // 
                this.verifyToolStripMenuItem.Name = "verifyToolStripMenuItem";
                this.verifyToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
                this.verifyToolStripMenuItem.Text = "Verify Insert";
                // 
                // simulateToolStripMenuItem
                // 
                this.simulateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.simulateRegExToolStripMenuItem,
                this.resultToolStripMenuItem});
                this.simulateToolStripMenuItem.Name = "simulateToolStripMenuItem";
                this.simulateToolStripMenuItem.Size = new System.Drawing.Size(59, 20);
                this.simulateToolStripMenuItem.Text = "Simulate";
                // 
                // simulateRegExToolStripMenuItem
                // 
                this.simulateRegExToolStripMenuItem.Name = "simulateRegExToolStripMenuItem";
                this.simulateRegExToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
                this.simulateRegExToolStripMenuItem.Text = "Simulate RegEx";
                // 
                // resultToolStripMenuItem
                // 
                this.resultToolStripMenuItem.Name = "resultToolStripMenuItem";
                this.resultToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
                this.resultToolStripMenuItem.Text = "Result";
                // 
                // compareToolStripMenuItem
                // 
                this.compareToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.compareFilesToolStripMenuItem,
                this.compareSectionsToolStripMenuItem});
                this.compareToolStripMenuItem.Name = "compareToolStripMenuItem";
                this.compareToolStripMenuItem.Size = new System.Drawing.Size(62, 20);
                this.compareToolStripMenuItem.Text = "Compare";
                // 
                // compareFilesToolStripMenuItem
                // 
                this.compareFilesToolStripMenuItem.Name = "compareFilesToolStripMenuItem";
                this.compareFilesToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
                this.compareFilesToolStripMenuItem.Text = "Compare Files";
                // 
                // compareSectionsToolStripMenuItem
                // 
                this.compareSectionsToolStripMenuItem.Name = "compareSectionsToolStripMenuItem";
                this.compareSectionsToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
                this.compareSectionsToolStripMenuItem.Text = "Compare Sections";
                // 
                // helpToolStripMenuItem
                // 
                this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.indenteToolStripMenuItem,
                this.xMLTreeToolStripMenuItem,
                this.findToolStripMenuItem,
                this.configurationToolStripMenuItem,
                this.includeToolStripMenuItem});
                this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
                this.helpToolStripMenuItem.Size = new System.Drawing.Size(41, 20);
                this.helpToolStripMenuItem.Text = "View";
                // 
                // indenteToolStripMenuItem
                // 
                this.indenteToolStripMenuItem.Name = "indenteToolStripMenuItem";
                this.indenteToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
                this.indenteToolStripMenuItem.Text = "Indente";
                this.indenteToolStripMenuItem.Click += new System.EventHandler(this.indenteToolStripMenuItem_Click);
                // 
                // xMLTreeToolStripMenuItem
                // 
                this.xMLTreeToolStripMenuItem.Name = "xMLTreeToolStripMenuItem";
                this.xMLTreeToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
                this.xMLTreeToolStripMenuItem.Text = "XML Tree";
                this.xMLTreeToolStripMenuItem.Click += new System.EventHandler(this.xMLTreeToolStripMenuItem_Click);
                // 
                // findToolStripMenuItem
                // 
                this.findToolStripMenuItem.Name = "findToolStripMenuItem";
                this.findToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
                this.findToolStripMenuItem.Text = "Find";
                this.findToolStripMenuItem.Click += new System.EventHandler(this.findToolStripMenuItem_Click);
                // 
                // configurationToolStripMenuItem
                // 
                this.configurationToolStripMenuItem.Name = "configurationToolStripMenuItem";
                this.configurationToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
                this.configurationToolStripMenuItem.Text = "configuration";
                // 
                // includeToolStripMenuItem
                // 
                this.includeToolStripMenuItem.Name = "includeToolStripMenuItem";
                this.includeToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
                this.includeToolStripMenuItem.Text = "Include";
                // 
                // validateToolStripMenuItem
                // 
                this.validateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.xSDToolStripMenuItem});
                this.validateToolStripMenuItem.Name = "validateToolStripMenuItem";
                this.validateToolStripMenuItem.Size = new System.Drawing.Size(57, 20);
                this.validateToolStripMenuItem.Text = "validate";
                // 
                // xSDToolStripMenuItem
                // 
                this.xSDToolStripMenuItem.Name = "xSDToolStripMenuItem";
                this.xSDToolStripMenuItem.Size = new System.Drawing.Size(93, 22);
                this.xSDToolStripMenuItem.Text = "XSD";
                this.xSDToolStripMenuItem.Click += new System.EventHandler(this.xSDToolStripMenuItem_Click);
                // 
                // helpToolStripMenuItem1
                // 
                this.helpToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.howToUseToolStripMenuItem,
                this.helpTagsToolStripMenuItem,
                this.aboutToolStripMenuItem});
                this.helpToolStripMenuItem1.Name = "helpToolStripMenuItem1";
                this.helpToolStripMenuItem1.Size = new System.Drawing.Size(40, 20);
                this.helpToolStripMenuItem1.Text = "Help";
                // 
                // howToUseToolStripMenuItem
                // 
                this.howToUseToolStripMenuItem.Name = "howToUseToolStripMenuItem";
                this.howToUseToolStripMenuItem.Size = new System.Drawing.Size(128, 22);
                this.howToUseToolStripMenuItem.Text = "How to use";
                // 
                // helpTagsToolStripMenuItem
                // 
                this.helpTagsToolStripMenuItem.Name = "helpTagsToolStripMenuItem";
                this.helpTagsToolStripMenuItem.Size = new System.Drawing.Size(128, 22);
                this.helpTagsToolStripMenuItem.Text = "Help Tags";
                // 
                // aboutToolStripMenuItem
                // 
                this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
                this.aboutToolStripMenuItem.Size = new System.Drawing.Size(128, 22);
                this.aboutToolStripMenuItem.Text = "About";
                // 
                // contextMenuStrip3
                // 
                this.contextMenuStrip3.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.closeToolStripMenuItem2});
                this.contextMenuStrip3.Name = "contextMenuStrip3";
                this.contextMenuStrip3.Size = new System.Drawing.Size(101, 26);
                // 
                // closeToolStripMenuItem2
                // 
                this.closeToolStripMenuItem2.Name = "closeToolStripMenuItem2";
                this.closeToolStripMenuItem2.Size = new System.Drawing.Size(100, 22);
                this.closeToolStripMenuItem2.Text = "Close";
                this.closeToolStripMenuItem2.Click += new System.EventHandler(this.closeToolStripMenuItem3_Click);
                // 
                // contextMenuStrip1
                // 
                this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.closeToolStripMenuItem});
                this.contextMenuStrip1.Name = "contextMenuStrip1";
                this.contextMenuStrip1.Size = new System.Drawing.Size(99, 70);
                // 
                // closeToolStripMenuItem
                // 
                this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
                this.closeToolStripMenuItem.Size = new System.Drawing.Size(98, 22);
                this.closeToolStripMenuItem.Text = "close";
                // 
                // contextMenuStrip2
                // 
                this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.closeToolStripMenuItem1,
                this.enfinToolStripMenuItem});
                this.contextMenuStrip2.Name = "contextMenuStrip2";
                this.contextMenuStrip2.Size = new System.Drawing.Size(102, 48);
                // 
                // closeToolStripMenuItem1
                // 
                this.closeToolStripMenuItem1.Name = "closeToolStripMenuItem1";
                this.closeToolStripMenuItem1.Size = new System.Drawing.Size(101, 22);
                this.closeToolStripMenuItem1.Text = "close ";
                // 
                // enfinToolStripMenuItem
                // 
                this.enfinToolStripMenuItem.Name = "enfinToolStripMenuItem";
                this.enfinToolStripMenuItem.Size = new System.Drawing.Size(101, 22);
                this.enfinToolStripMenuItem.Text = "enfin";
                // 
                // splitContainer1
                // 
                this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
                this.splitContainer1.Location = new System.Drawing.Point(0, 24);
                this.splitContainer1.Name = "splitContainer1";
                // 
                // splitContainer1.Panel1
                // 
                this.splitContainer1.Panel1.Controls.Add(this.treeView1);
                // 
                // splitContainer1.Panel2
                // 
                this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
                this.splitContainer1.Size = new System.Drawing.Size(726, 409);
                this.splitContainer1.SplitterDistance = 128;
                this.splitContainer1.TabIndex = 4;
                // 
                // treeView1
                // 
                this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
                this.treeView1.Location = new System.Drawing.Point(0, 0);
                this.treeView1.Name = "treeView1";
                this.treeView1.Size = new System.Drawing.Size(128, 409);
                this.treeView1.TabIndex = 5;
                this.treeView1.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseDoubleClick);
                // 
                // splitContainer2
                // 
                this.splitContainer2.AccessibleRole = System.Windows.Forms.AccessibleRole.Grip;
                this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
                this.splitContainer2.Location = new System.Drawing.Point(0, 0);
                this.splitContainer2.Name = "splitContainer2";
                this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
                // 
                // splitContainer2.Panel1
                // 
                this.splitContainer2.Panel1.Controls.Add(this.tabControl1);
                // 
                // splitContainer2.Panel2
                // 
                this.splitContainer2.Panel2.Controls.Add(this.console);
                this.splitContainer2.Size = new System.Drawing.Size(594, 409);
                this.splitContainer2.SplitterDistance = 357;
                this.splitContainer2.TabIndex = 0;
                // 
                // tabControl1
                // 
                this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
                this.tabControl1.Location = new System.Drawing.Point(0, 0);
                this.tabControl1.Name = "tabControl1";
                this.tabControl1.SelectedIndex = 0;
                this.tabControl1.Size = new System.Drawing.Size(594, 357);
                this.tabControl1.TabIndex = 0;
                this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
                // 
                // console
                // 
                this.console.Dock = System.Windows.Forms.DockStyle.Fill;
                this.console.Location = new System.Drawing.Point(0, 0);
                this.console.Name = "console";
                this.console.Size = new System.Drawing.Size(594, 48);
                this.console.TabIndex = 0;
                this.console.Text = "";
                // 
                // errorProvider1
                // 
                this.errorProvider1.ContainerControl = this;
                // 
                // MainForm
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.BackColor = System.Drawing.Color.LightBlue;
                this.ClientSize = new System.Drawing.Size(726, 433);
                this.Controls.Add(this.splitContainer1);
                this.Controls.Add(this.menuStrip1);
                this.MainMenuStrip = this.menuStrip1;
                this.Name = "MainForm";
                this.Text = "test";
                this.menuStrip1.ResumeLayout(false);
                this.menuStrip1.PerformLayout();
                this.contextMenuStrip3.ResumeLayout(false);
                this.contextMenuStrip1.ResumeLayout(false);
                this.contextMenuStrip2.ResumeLayout(false);
                this.splitContainer1.Panel1.ResumeLayout(false);
                this.splitContainer1.Panel2.ResumeLayout(false);
                this.splitContainer1.ResumeLayout(false);
                this.splitContainer2.Panel1.ResumeLayout(false);
                this.splitContainer2.Panel2.ResumeLayout(false);
                this.splitContainer2.ResumeLayout(false);
                ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).EndInit();
                this.ResumeLayout(false);
                this.PerformLayout();
     
            }
    		private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem helpTagsToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem howToUseToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem1;
    		private System.Windows.Forms.ToolStripMenuItem indenteToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem compareSectionsToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem compareFilesToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem compareToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem resultToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem simulateRegExToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem simulateToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem verifyToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem insertTagToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem insertToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
    		private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
            private System.Windows.Forms.MenuStrip menuStrip1;
            private System.Windows.Forms.ToolStripMenuItem xMLTreeToolStripMenuItem;
            private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
            private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem;
            private System.Windows.Forms.ContextMenuStrip contextMenuStrip2;
            private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem1;
            private System.Windows.Forms.ToolStripMenuItem enfinToolStripMenuItem;
            private System.Windows.Forms.ContextMenuStrip contextMenuStrip3;
            private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem2;
            private System.Windows.Forms.ToolStripMenuItem configurationToolStripMenuItem;
            private System.Windows.Forms.ToolStripMenuItem saveFileToolStripMenuItem;
            private System.Windows.Forms.ToolStripMenuItem validateToolStripMenuItem;
            private System.Windows.Forms.ToolStripMenuItem xSDToolStripMenuItem;
            private System.Windows.Forms.SplitContainer splitContainer1;
            private System.Windows.Forms.TreeView treeView1;
            private System.Windows.Forms.ErrorProvider errorProvider1;
            private System.Windows.Forms.SplitContainer splitContainer2;
            public System.Windows.Forms.TabControl tabControl1;
            public System.Windows.Forms.RichTextBox console;
            private System.Windows.Forms.ToolStripMenuItem findToolStripMenuItem;
            private System.Windows.Forms.ToolStripMenuItem includeToolStripMenuItem;
     
     
     
     
    	}
    }


    et l'élément dont j'ai besoin c'est : tabControl1

  4. #4
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Points : 39 749
    Points
    39 749
    Par défaut
    ben ça me semble correct
    qu'est-ce qu'il te dit le compilateur ?

  5. #5
    Membre régulier
    Étudiant
    Inscrit en
    Août 2008
    Messages
    349
    Détails du profil
    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2008
    Messages : 349
    Points : 93
    Points
    93
    Par défaut
    voici le code que je veux éxécuter :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    private void replaceb_Click(object sender, EventArgs e)
            {
     
                MainForm mf = new MainForm();
                Find f = new Find();
                RichTextBox rtb = (RichTextBox)mf.tabControl1.SelectedTab.Controls[0];
                f.replace(rtb, mf.console, findf, replacef);
            }
    lors de l'exécution voici le message que j'obtiens :
    la référence d'objet n'est pas définie à une instance d'un objet

  6. #6
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Points : 39 749
    Points
    39 749
    Par défaut
    ah ok, donc y a pas d'erreur de compilation, c'est à l'exécution que ça plante... ça n'a rien à voir avec le problème que tu décrivais au départ

    D'abord, pourquoi tu crées une nouvelle instance de MainForm ? c'est plutôt sur l'instance courante (this) que tu devrais travailler, non ? Sinon, je ne sais pas ce qu'il y a dans ta classe Find...

    Sur quelle ligne ça plante ?

  7. #7
    Membre régulier
    Étudiant
    Inscrit en
    Août 2008
    Messages
    349
    Détails du profil
    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2008
    Messages : 349
    Points : 93
    Points
    93
    Par défaut
    ça plante sur la ligne de définition de rtb,
    et je ne peux pas utiliser this car je ne suis pas dans la classe mainForm je suis sur une autre classe qui contient un petite interface permettant d'entrer les à cherché et remplacé.

  8. #8
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Points : 39 749
    Points
    39 749
    Par défaut
    Citation Envoyé par TaymouWan Voir le message
    je ne peux pas utiliser this car je ne suis pas dans la classe mainForm je suis sur une autre classe qui contient un petite interface permettant d'entrer les à cherché et remplacé.
    Ben oui, mais si tu travailles sur une autre form que tu crées juste pour ça, ça ne risque pas de remplacer quoi que ce soit dans la form existante... il faut que, d'une manière ou d'une autre, tu récupères une instance de la form existante.

Discussions similaires

  1. Classes partagées entre deux threads, et erreur sur select()
    Par DakM dans le forum Threads & Processus
    Réponses: 1
    Dernier message: 11/05/2012, 17h21
  2. [Xaml/C#:CustomControl] Comment accéder à des éléments du Template?
    Par SuprazZz dans le forum Windows Presentation Foundation
    Réponses: 6
    Dernier message: 26/11/2008, 20h40
  3. Réponses: 7
    Dernier message: 28/12/2007, 23h08
  4. [Reflect] connaître la classe des éléments d'une collection
    Par El Saigneur dans le forum Collection et Stream
    Réponses: 1
    Dernier message: 12/06/2007, 12h04
  5. [dom je pense]accéder à des éléments d un tableau sans id
    Par luta dans le forum Général JavaScript
    Réponses: 10
    Dernier message: 07/02/2006, 15h31

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