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 :

Controle utilisateur, probleme d'interaction


Sujet :

Windows Forms

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Points : 12
    Points
    12
    Par défaut Controle utilisateur, probleme d'interaction
    Bonjour à tous,
    J'ai pour projet de faire un logiciel de gestion d'emploi du temps, pour cela j'ai fais un contrôle utilisateur "calendrier".

    Lorsque j'insert mon contrôle dans mon programme, tout se passe bien : toutes les propriété sont là, et il apparait parfaitement dans le [design].

    MAIS c'est impossible d’interagir avec dans le programme : Je ne peux pas changer la valeur des variables, ni des propriété. Cependant les méthodes du contrôle lui-même fonctionne parfaitement (le changement de mois par exemple).

    Exemple :

    Dans mon controle j'ai un tableau de DataGridView, donc pour changer la valeur d'une des cellule, je fais :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    calend.TabCaseCalend[15][1, 1].Value = "coucou";
    Mais ça ne s'affiche pas, il n'y a pas de message d'erreur pour autant.

    Je suis perdu parce que j'ai suivi le cours, donné par mon professeur, A LA LETTRE ^^ Mais ça ne fonctionne pas.

    Pouvez vous donc me dire d'où vient le soucis ? A la limite, une fois identifié, je pourrais le régler seul, mais ne sachant pas où il se trouve, je ne sais plus quoi faire


    Rhoblik.

    PS : Si vous voulez des détails en plus, n’hésitez pas, j’essaierai de vous les fournir.

  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
    Citation Envoyé par rhoblik Voir le message
    Pouvez vous donc me dire d'où vient le soucis ?
    Sans voir ton code, ça risque d'être difficile... on n'a pas de boule de cristal

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Points : 12
    Points
    12
    Par défaut
    C'est juste ^^'

    Du coup, concernant mon programme, le voici :

    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
     
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
     
    namespace Lis_Emploi_Temps
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
     
                Utile.InitPanelMenu(pnMenu);
                Utile.InitPanel(pnListCli);
                Utile.InitPanel(pnListInter);
                Utile.InitPanel(pnEmploiCli);
                Utile.InitPanel(pnEmploiInter);
     
                BaseDeDonnees.ConnexionBaseDeDonnees("Lis_services.mdb");
     
                calend = new calendrier_emploi_temps.calendrierEmploi();
            }
    //Fonction des diférents boutons, à changer car ils n'interfères pas avec le contrôle utilisateur.
    .
    .
    .
                private void calendrierEmploi1_cliqueBtAjout(object sender, EventArgs e)
                {
                    calend.TabCaseCalend[15][1, 1].Value = "coucou";
     
                    //MessageBox.Show("" + calend.TabCaseCalend[Convert.ToInt32(calend.AjJour)][1, 1].Value);
                    //MessageBox.Show("" + calend.AjActiv + " " + calend.AjJour);calend.AjActiv
                }
        }
    }
    Les commentaires servaient à afficher les différentes valeurs de mes variables, mais ça donnait des MessageBox vides :/
    J'ai été obligé de ré-instancier mon "calend", car il ne remplissait pas automatiquement le tableau de DataGridView (Qui, vous verrez juste après, se remplit dans le "Load" du contrôle ^^')


    Et ici, le code de mon contrôle (allégé pour plus de clarté) :

    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
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
     
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
     
    namespace calendrier_emploi_temps
    {
        public partial class calendrierEmploi : UserControl
        {
            #region Variable
     
                //Variable "visibles" pour l'utilisateur
                private string ajActiv;
                private string ajJour;
                private string ajHDeb;
                private string ajHFin;
                private string supHDeb; 
                private string supJour;
     
                public string AjActiv
                {
                    get { return ajActiv; }
                    set { ajActiv = value; }
                }
                //Meme chose ensuite pour les autres variable du "paragraphe" précédent
     
     
                private DataGridView[] tabCaseCalend = new DataGridView[38]; //avec ça on a acces à toutes les cases du calendrier
     
                public DataGridView[] TabCaseCalend
                {
                    get { return tabCaseCalend; }
                    set { tabCaseCalend = value; }
                }
     
                public delegate void CliqueBtAjoutEventHandler(object sender, EventArgs e);
                public delegate void CliqueBtSuppEventHandler(object sender, EventArgs e);
                public delegate void CliqueBtSuivEventHandler(object sender, EventArgs e);
                public delegate void CliqueBtPresEventHandler(object sender, EventArgs e);
     
                public event CliqueBtAjoutEventHandler cliqueBtAjout;
                public event CliqueBtSuppEventHandler cliqueBtSupp;
                public event CliqueBtSuivEventHandler cliqueBtSuiv;
                public event CliqueBtPresEventHandler cliqueBtPres;
     
            #endregion
     
            public calendrierEmploi()
            {
                InitializeComponent();
     
                lbNomMois.Text = NomMois(idMoisNow);
                lbNomAnnee.Text = Convert.ToString(idAnneeNow);
                idJourSemPremMoisGeneral = IdPremierJourMois(idJourMoisNow, idJourSemAnglais(nomJourSemAnglaisNow));
     
                noJourInit = IdCommenceCumulJour(idJourSemPremMoisGeneral);
                nbJourTotMois = NbJourMois(idMoisNow, idAnneeNow);
     
                //Creation du tableau
                CreerTableauCaseJourMois(noJourInit, posiIniX, posiIniY, taille, nbJourTotMois);
     
                InitTabCaseCalend(noJourInit);
            }
     
            #region Annexes
                private void InitDgv(DataGridView dgv, ref Point posi, Size taille, ref int noJour, int nbJourMois)
                {
                    //Redevien visible si il etait caché, on supprime les lignes et les colonnes (sinon ça se cumul, logique) ^^
                    if (dgv.Rows.Count > 0) //detecte si le dgv à été initialisé ^^'
                    {
                        dgv.Visible = true;
                        dgv.Columns.Remove("numCli");
                        dgv.Columns.Remove("nomCli");
                        dgv.Columns.Remove("HDeb");
                        dgv.Columns.Remove("HFin");
                    }
     
                    //Puis on l'initialise
                    dgv.Location = posi;
                    dgv.Size = taille;
     
                    dgv.Columns.Add("numCli", "Num");
                    dgv.Columns.Add("nomCli", "Nom");
                    dgv.Columns.Add("HDeb", "Debut");
                    dgv.Columns.Add("HFin", "Fin");
     
                    dgv.Rows.Add();
                    dgv.Rows.Add();
                    dgv.Rows.Add();
                    dgv.Rows.Add();
                    dgv.Rows.Add();
                    dgv.Rows.Add();
                    dgv.Rows.Add();
                    dgv.Rows.Add();
                    dgv.Rows.Add();
     
                    dgv.Columns[1].Width = 100;
                    dgv.Columns[2].Width = 40;
                    dgv.Columns[3].Width = 40;
                    for (int i = 0; i < dgv.Rows.Count; i++)
                    {
                        dgv.Rows[i].Height = 12;
                    }
                    dgv.Columns[0].Visible = false;
                    dgv.ColumnHeadersVisible = false;
                    dgv.RowHeadersVisible = false;
                    dgv.AllowUserToAddRows = false;
                    dgv.AllowUserToResizeColumns = false;
                    dgv.AllowUserToResizeRows = false;
     
                    dgv[1, 0].Value = noJour;
     
                    if (noJour < 1 || noJour > nbJourMois)
                    {
                        dgv.Visible = false;
                    }
     
                    //les deux modifications
                    noJour = noJour + 7;
                    posi = new Point(posi.X, posi.Y + taille.Height);
                }
                private void CreerTableauCaseJourMois(int noJourInit, int posiIniX, int posiIniY, Size taille, int nbJourTotMois)
                {
                    int noJour = noJourInit;
                    Point posi = new Point(posiIniX, posiIniY);
                    InitDgv(dgvL1, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvL2, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvL3, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvL4, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvL5, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvL6, ref posi, taille, ref noJour, nbJourTotMois);
     
                    posi = new Point(posiIniX + taille.Width, posiIniY);
                    noJour = noJourInit + 1;
                    InitDgv(dgvM1, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvM2, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvM3, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvM4, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvM5, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvM6, ref posi, taille, ref noJour, nbJourTotMois);
     
                    posi = new Point(posiIniX + taille.Width * 2, posiIniY);
                    noJour = noJourInit + 2;
                    InitDgv(dgvMe1, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvMe2, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvMe3, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvMe4, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvMe5, ref posi, taille, ref noJour, nbJourTotMois);
     
                    posi = new Point(posiIniX + taille.Width * 3, posiIniY);
                    noJour = noJourInit + 3;
                    InitDgv(dgvJ1, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvJ2, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvJ3, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvJ4, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvJ5, ref posi, taille, ref noJour, nbJourTotMois);
     
                    posi = new Point(posiIniX + taille.Width * 4, posiIniY);
                    noJour = noJourInit + 4;
                    InitDgv(dgvV1, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvV2, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvV3, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvV4, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvV5, ref posi, taille, ref noJour, nbJourTotMois);
     
                    posi = new Point(posiIniX + taille.Width * 5, posiIniY);
                    noJour = noJourInit + 5;
                    InitDgv(dgvS1, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvS2, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvS3, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvS4, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvS5, ref posi, taille, ref noJour, nbJourTotMois);
     
                    posi = new Point(posiIniX + taille.Width * 6, posiIniY);
                    noJour = noJourInit + 6;
                    InitDgv(dgvD1, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvD2, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvD3, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvD4, ref posi, taille, ref noJour, nbJourTotMois);
                    InitDgv(dgvD5, ref posi, taille, ref noJour, nbJourTotMois);
                }
                private void InitTabCaseCalend(int premJourMois)
                {
                    switch (premJourMois)
                    {
                        case 1:
                            tabCaseCalend[0] = dgvL1;
                            tabCaseCalend[1] = dgvM1;
                            tabCaseCalend[2] = dgvMe1;
                            tabCaseCalend[3] = dgvJ1;
                            tabCaseCalend[4] = dgvV1;
                            tabCaseCalend[5] = dgvS1;
                            tabCaseCalend[6] = dgvD1;
                            tabCaseCalend[7] = dgvL2;
                            tabCaseCalend[8] = dgvM2;
                            tabCaseCalend[9] = dgvMe2;
                            tabCaseCalend[10] = dgvJ2;
                            tabCaseCalend[11] = dgvV2;
                            tabCaseCalend[12] = dgvS2;
                            tabCaseCalend[13] = dgvD2;
                            tabCaseCalend[14] = dgvL3;
                            tabCaseCalend[15] = dgvM3;
                            tabCaseCalend[16] = dgvMe3;
                            tabCaseCalend[17] = dgvJ3;
                            tabCaseCalend[18] = dgvV3;
                            tabCaseCalend[19] = dgvS3;
                            tabCaseCalend[20] = dgvD3;
                            tabCaseCalend[21] = dgvL4;
                            tabCaseCalend[22] = dgvM4;
                            tabCaseCalend[23] = dgvMe4;
                            tabCaseCalend[24] = dgvJ4;
                            tabCaseCalend[25] = dgvV4;
                            tabCaseCalend[26] = dgvS4;
                            tabCaseCalend[27] = dgvD4;
                            tabCaseCalend[28] = dgvL5;
                            tabCaseCalend[29] = dgvM5;
                            tabCaseCalend[30] = dgvMe5;
                            tabCaseCalend[31] = dgvJ5;
                            tabCaseCalend[32] = dgvV5;
                            tabCaseCalend[33] = dgvS5;
                            tabCaseCalend[34] = dgvD5;
                            tabCaseCalend[35] = dgvL6;
                            tabCaseCalend[36] = dgvM6;
                            break;
     
                        case 0:
                            tabCaseCalend[36] = dgvL1;
                            tabCaseCalend[0] = dgvM1;
                            tabCaseCalend[1] = dgvMe1;
                            tabCaseCalend[2] = dgvJ1;
                            tabCaseCalend[3] = dgvV1;
                            tabCaseCalend[4] = dgvS1;
                            tabCaseCalend[5] = dgvD1;
                            tabCaseCalend[6] = dgvL2;
                            tabCaseCalend[7] = dgvM2;
                            tabCaseCalend[8] = dgvMe2;
                            tabCaseCalend[9] = dgvJ2;
                            tabCaseCalend[10] = dgvV2;
                            tabCaseCalend[11] = dgvS2;
                            tabCaseCalend[12] = dgvD2;
                            tabCaseCalend[13] = dgvL3;
                            tabCaseCalend[14] = dgvM3;
                            tabCaseCalend[15] = dgvMe3;
                            tabCaseCalend[16] = dgvJ3;
                            tabCaseCalend[17] = dgvV3;
                            tabCaseCalend[18] = dgvS3;
                            tabCaseCalend[19] = dgvD3;
                            tabCaseCalend[20] = dgvL4;
                            tabCaseCalend[21] = dgvM4;
                            tabCaseCalend[22] = dgvMe4;
                            tabCaseCalend[23] = dgvJ4;
                            tabCaseCalend[24] = dgvV4;
                            tabCaseCalend[25] = dgvS4;
                            tabCaseCalend[26] = dgvD4;
                            tabCaseCalend[27] = dgvL5;
                            tabCaseCalend[28] = dgvM5;
                            tabCaseCalend[29] = dgvMe5;
                            tabCaseCalend[30] = dgvJ5;
                            tabCaseCalend[31] = dgvV5;
                            tabCaseCalend[32] = dgvS5;
                            tabCaseCalend[33] = dgvD5;
                            tabCaseCalend[34] = dgvL6;
                            tabCaseCalend[35] = dgvM6;
                            break;
     
                        case -1:
                            tabCaseCalend[35] = dgvL1;
                            tabCaseCalend[36] = dgvM1;
                            tabCaseCalend[0] = dgvMe1;
                            tabCaseCalend[1] = dgvJ1;
                            tabCaseCalend[2] = dgvV1;
                            tabCaseCalend[3] = dgvS1;
                            tabCaseCalend[4] = dgvD1;
                            tabCaseCalend[5] = dgvL2;
                            tabCaseCalend[6] = dgvM2;
                            tabCaseCalend[7] = dgvMe2;
                            tabCaseCalend[8] = dgvJ2;
                            tabCaseCalend[9] = dgvV2;
                            tabCaseCalend[10] = dgvS2;
                            tabCaseCalend[11] = dgvD2;
                            tabCaseCalend[12] = dgvL3;
                            tabCaseCalend[13] = dgvM3;
                            tabCaseCalend[14] = dgvMe3;
                            tabCaseCalend[15] = dgvJ3;
                            tabCaseCalend[16] = dgvV3;
                            tabCaseCalend[17] = dgvS3;
                            tabCaseCalend[18] = dgvD3;
                            tabCaseCalend[19] = dgvL4;
                            tabCaseCalend[20] = dgvM4;
                            tabCaseCalend[21] = dgvMe4;
                            tabCaseCalend[22] = dgvJ4;
                            tabCaseCalend[23] = dgvV4;
                            tabCaseCalend[24] = dgvS4;
                            tabCaseCalend[25] = dgvD4;
                            tabCaseCalend[26] = dgvL5;
                            tabCaseCalend[27] = dgvM5;
                            tabCaseCalend[28] = dgvMe5;
                            tabCaseCalend[29] = dgvJ5;
                            tabCaseCalend[30] = dgvV5;
                            tabCaseCalend[31] = dgvS5;
                            tabCaseCalend[32] = dgvD5;
                            tabCaseCalend[33] = dgvL6;
                            tabCaseCalend[34] = dgvM6;
                            break;
     
                        case -2:
                            tabCaseCalend[34] = dgvL1;
                            tabCaseCalend[35] = dgvM1;
                            tabCaseCalend[36] = dgvMe1;
                            tabCaseCalend[0] = dgvJ1;
                            tabCaseCalend[1] = dgvV1;
                            tabCaseCalend[2] = dgvS1;
                            tabCaseCalend[3] = dgvD1;
                            tabCaseCalend[4] = dgvL2;
                            tabCaseCalend[5] = dgvM2;
                            tabCaseCalend[6] = dgvMe2;
                            tabCaseCalend[7] = dgvJ2;
                            tabCaseCalend[8] = dgvV2;
                            tabCaseCalend[9] = dgvS2;
                            tabCaseCalend[10] = dgvD2;
                            tabCaseCalend[11] = dgvL3;
                            tabCaseCalend[12] = dgvM3;
                            tabCaseCalend[13] = dgvMe3;
                            tabCaseCalend[14] = dgvJ3;
                            tabCaseCalend[15] = dgvV3;
                            tabCaseCalend[16] = dgvS3;
                            tabCaseCalend[17] = dgvD3;
                            tabCaseCalend[18] = dgvL4;
                            tabCaseCalend[19] = dgvM4;
                            tabCaseCalend[20] = dgvMe4;
                            tabCaseCalend[21] = dgvJ4;
                            tabCaseCalend[22] = dgvV4;
                            tabCaseCalend[23] = dgvS4;
                            tabCaseCalend[24] = dgvD4;
                            tabCaseCalend[25] = dgvL5;
                            tabCaseCalend[26] = dgvM5;
                            tabCaseCalend[27] = dgvMe5;
                            tabCaseCalend[28] = dgvJ5;
                            tabCaseCalend[29] = dgvV5;
                            tabCaseCalend[30] = dgvS5;
                            tabCaseCalend[31] = dgvD5;
                            tabCaseCalend[32] = dgvL6;
                            tabCaseCalend[33] = dgvM6;
                            break;
     
                        case -3:
                            tabCaseCalend[33] = dgvL1;
                            tabCaseCalend[34] = dgvM1;
                            tabCaseCalend[35] = dgvMe1;
                            tabCaseCalend[36] = dgvJ1;
                            tabCaseCalend[0] = dgvV1;
                            tabCaseCalend[1] = dgvS1;
                            tabCaseCalend[2] = dgvD1;
                            tabCaseCalend[3] = dgvL2;
                            tabCaseCalend[4] = dgvM2;
                            tabCaseCalend[5] = dgvMe2;
                            tabCaseCalend[6] = dgvJ2;
                            tabCaseCalend[7] = dgvV2;
                            tabCaseCalend[8] = dgvS2;
                            tabCaseCalend[9] = dgvD2;
                            tabCaseCalend[10] = dgvL3;
                            tabCaseCalend[11] = dgvM3;
                            tabCaseCalend[12] = dgvMe3;
                            tabCaseCalend[13] = dgvJ3;
                            tabCaseCalend[14] = dgvV3;
                            tabCaseCalend[15] = dgvS3;
                            tabCaseCalend[16] = dgvD3;
                            tabCaseCalend[17] = dgvL4;
                            tabCaseCalend[18] = dgvM4;
                            tabCaseCalend[19] = dgvMe4;
                            tabCaseCalend[20] = dgvJ4;
                            tabCaseCalend[21] = dgvV4;
                            tabCaseCalend[22] = dgvS4;
                            tabCaseCalend[23] = dgvD4;
                            tabCaseCalend[24] = dgvL5;
                            tabCaseCalend[25] = dgvM5;
                            tabCaseCalend[26] = dgvMe5;
                            tabCaseCalend[27] = dgvJ5;
                            tabCaseCalend[28] = dgvV5;
                            tabCaseCalend[29] = dgvS5;
                            tabCaseCalend[30] = dgvD5;
                            tabCaseCalend[31] = dgvL6;
                            tabCaseCalend[32] = dgvM6;
                            break;
     
                        case -4:
                            tabCaseCalend[32] = dgvL1;
                            tabCaseCalend[33] = dgvM1;
                            tabCaseCalend[34] = dgvMe1;
                            tabCaseCalend[35] = dgvJ1;
                            tabCaseCalend[36] = dgvV1;
                            tabCaseCalend[0] = dgvS1;
                            tabCaseCalend[1] = dgvD1;
                            tabCaseCalend[2] = dgvL2;
                            tabCaseCalend[3] = dgvM2;
                            tabCaseCalend[4] = dgvMe2;
                            tabCaseCalend[5] = dgvJ2;
                            tabCaseCalend[6] = dgvV2;
                            tabCaseCalend[7] = dgvS2;
                            tabCaseCalend[8] = dgvD2;
                            tabCaseCalend[9] = dgvL3;
                            tabCaseCalend[10] = dgvM3;
                            tabCaseCalend[11] = dgvMe3;
                            tabCaseCalend[12] = dgvJ3;
                            tabCaseCalend[13] = dgvV3;
                            tabCaseCalend[14] = dgvS3;
                            tabCaseCalend[15] = dgvD3;
                            tabCaseCalend[16] = dgvL4;
                            tabCaseCalend[17] = dgvM4;
                            tabCaseCalend[18] = dgvMe4;
                            tabCaseCalend[19] = dgvJ4;
                            tabCaseCalend[20] = dgvV4;
                            tabCaseCalend[21] = dgvS4;
                            tabCaseCalend[22] = dgvD4;
                            tabCaseCalend[23] = dgvL5;
                            tabCaseCalend[24] = dgvM5;
                            tabCaseCalend[25] = dgvMe5;
                            tabCaseCalend[26] = dgvJ5;
                            tabCaseCalend[27] = dgvV5;
                            tabCaseCalend[28] = dgvS5;
                            tabCaseCalend[29] = dgvD5;
                            tabCaseCalend[30] = dgvL6;
                            tabCaseCalend[31] = dgvM6;
                            break;
     
                        case -5:
                            tabCaseCalend[31] = dgvL1;
                            tabCaseCalend[32] = dgvM1;
                            tabCaseCalend[33] = dgvMe1;
                            tabCaseCalend[34] = dgvJ1;
                            tabCaseCalend[35] = dgvV1;
                            tabCaseCalend[36] = dgvS1;
                            tabCaseCalend[0] = dgvD1;
                            tabCaseCalend[1] = dgvL2;
                            tabCaseCalend[2] = dgvM2;
                            tabCaseCalend[3] = dgvMe2;
                            tabCaseCalend[4] = dgvJ2;
                            tabCaseCalend[5] = dgvV2;
                            tabCaseCalend[6] = dgvS2;
                            tabCaseCalend[7] = dgvD2;
                            tabCaseCalend[8] = dgvL3;
                            tabCaseCalend[9] = dgvM3;
                            tabCaseCalend[10] = dgvMe3;
                            tabCaseCalend[11] = dgvJ3;
                            tabCaseCalend[12] = dgvV3;
                            tabCaseCalend[13] = dgvS3;
                            tabCaseCalend[14] = dgvD3;
                            tabCaseCalend[15] = dgvL4;
                            tabCaseCalend[16] = dgvM4;
                            tabCaseCalend[17] = dgvMe4;
                            tabCaseCalend[18] = dgvJ4;
                            tabCaseCalend[19] = dgvV4;
                            tabCaseCalend[20] = dgvS4;
                            tabCaseCalend[21] = dgvD4;
                            tabCaseCalend[22] = dgvL5;
                            tabCaseCalend[23] = dgvM5;
                            tabCaseCalend[24] = dgvMe5;
                            tabCaseCalend[25] = dgvJ5;
                            tabCaseCalend[26] = dgvV5;
                            tabCaseCalend[27] = dgvS5;
                            tabCaseCalend[28] = dgvD5;
                            tabCaseCalend[29] = dgvL6;
                            tabCaseCalend[30] = dgvM6;
                            break;
                    }
                }
     
                private int IdCommenceCumulJour(int idJourSem)
                {
                    int idCommence = 0;
                    int indiceJour = 7 - idJourSem;
                    switch (indiceJour)
                    {
                        case 0: idCommence = -5;
                            break;
     
                        case 1: idCommence = -4;
                            break;
     
                        case 2: idCommence = -3;
                            break;
     
                        case 3: idCommence = -2;
                            break;
     
                        case 4: idCommence = -1;
                            break;
     
                        case 5: idCommence = 0;
                            break;
     
                        case 6: idCommence = 1;
                            break;
                    }
                    return idCommence;
                }
            #endregion
     
            #region Controles
                private void btMoisSuiv_Click(object sender, EventArgs e)
                {
                    //On prend l'id du nom du jour de la semaine (Lundi = 1) qui tombe le dernier jour du mois (31) et on fait +1 ^^ tout simplement => "Pourquoi faire simple quand on peut faire compliquer" ^^'
                    int idJourSemDer = ChangerIdJourSem(NbJourMois(idMoisNow, idAnneeNow) - 1, idJourSemPremMoisGeneral, true);
     
                    idMoisNow = idMoisNow + 1;
                    if (idMoisNow > 12)
                    {
                        idMoisNow = 1;
                        idAnneeNow = idAnneeNow + 1;
                    }
     
                    lbNomMois.Text = NomMois(idMoisNow);
                    lbNomAnnee.Text = Convert.ToString(idAnneeNow);
                    idJourSemPremMoisGeneral = idJourSemDer + 1;
                    if (idJourSemPremMoisGeneral > 7)
                    {
                        idJourSemPremMoisGeneral = 1;
                    }
     
                    //Creation tableau
                    noJourInit = IdCommenceCumulJour(idJourSemPremMoisGeneral);
                    nbJourTotMois = NbJourMois(idMoisNow, idAnneeNow);
     
                    CreerTableauCaseJourMois(noJourInit, posiIniX, posiIniY, taille, nbJourTotMois);
                    InitTabCaseCalend(noJourInit);
     
                    //Quand l'utilisateur clique sur ce bouton
                    if (cliqueBtSuiv != null)
                    {
                        cliqueBtSuiv(this, e);
                    }
                }
          //Pareil pour le bouton "Mois précédent"
     
                //Ajout évenement
                private void tbJourActi_Leave(object sender, EventArgs e)
                {
                    if (tbJourActi.Text.Length == 1)
                    {
                        tbJourActi.Text = "0" + tbJourActi.Text;
                    }
                }
                private void tbNomActi_TextChanged(object sender, EventArgs e)
                {
                    ajActiv = tbNomActi.Text;
                }
                private void tbJourActi_TextChanged(object sender, EventArgs e)
                {
                    if (tbJourActi.Text.Length == 2)
                    {
                        tbHDebActi.SelectionStart = 0;
                    }
                    ajJour = tbJourActi.Text;
                }
                private void tbHDebActi_TextChanged(object sender, EventArgs e)
                {
                    FiltreHeure(tbHDebActi);
     
                    if (tbHDebActi.Text.Length == 5)
                    {
                        tbHFinActi.SelectionStart = 0;
                    }
                    ajHDeb = tbHDebActi.Text;
                }
                private void tbHFinActi_TextChanged(object sender, EventArgs e)
                {
                    FiltreHeure(tbHFinActi);
                    ajHFin = tbHFinActi.Text;
                }
     
                private void btAjoutActi_Click(object sender, EventArgs e)
                {
                    if (tbNomActi.Text != "" && tbJourActi.Text != "" && tbHDebActi.Text != "" && tbHFinActi.Text != "" && tbHDebActi.Text.Length == 5 && tbHFinActi.Text.Length == 5)
                    {
                        if (cliqueBtAjout != null)
                        {
                            cliqueBtAjout(this, e);
                        }
                        //MessageBox.Show("" + AjActiv);
                    }
                    else
                    {
                        MessageBox.Show("Vous n'avez pas rempli tous les champs.", "Erreur");
                    }
                }
     
                //Suppresion => pareil que pour l'ajout, à quelque changement près ^^
            #endregion
        }
    }
    (J'ai testé que sur le bouton "Ajout", sachant que si il n'y a rien, je ne peux pas supprimer ^^)
    Les boutons "suivant" et "précédent" fonctionnent. Du moins en ce qui concerne le code du contrôle.

    En espérant que c'est pas trop volumineux :/


    Rhoblik.

  4. #4
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Points : 12
    Points
    12
    Par défaut
    Bonjour,

    Alors voilà : Changement de problème.

    J'ai réussi à afficher des valeurs dans un de mes DGV, donc tout va bien de ce coté là finalement.
    Pour cela, j'ai enlevé la ré-instanciation de mon contrôle qui se trouvait dans le load de mon programme. Du coup mon contrôle est bien celui que j'ai mis dans mon programme.

    Cependant, mon problème est le suivant :
    Le remplissage de mon tableau de DataGridView ne se fait pas au lancement du programme, mais il se fait lorsque je clique sur "suivant" ou "précédent". (Alors que la méthode de remplissage est également appelée dans le constructeur de mon contrôle).

    Donc je ne comprends pas pourquoi mon tableau de DGV ne se remplis pas lorsque je lance mon programme.

    Que faut-il faire pour que le constructeur de mon contrôle s'instancie ?

    Rhoblik.

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Points : 12
    Points
    12
    Par défaut
    Bonjour,

    J'ai trouvé une solution alternative (bricolage ^^')

    J'ai compris que ma méthode "InitTabCaseCalend" n'était pas appelée dans le constructeur de mon contrôle (bien qu'elle y soit inscrite....).

    Donc j'ai tout simplement passé "public" cette méthode et son paramètre, pour les appeler dans le load de mon programme. Et tout fonctionne comme il faut !!

    Rhoblik.

    PS : Comme quoi, exposer nos problèmes aux autres, peut nous servir à éclaircir le problème ^^

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

Discussions similaires

  1. Probleme de passage de donnée dans un control utilisateur
    Par Luciol44 dans le forum Windows Forms
    Réponses: 1
    Dernier message: 07/03/2010, 12h44
  2. [VB.Net] Regrouper des controles utilisateurs
    Par Jsh dans le forum Windows Forms
    Réponses: 4
    Dernier message: 07/04/2006, 13h39
  3. [VB]Gérer la liaison entre controle utilisateur et form
    Par Ooly2001 dans le forum VB 6 et antérieur
    Réponses: 19
    Dernier message: 23/01/2006, 09h50
  4. Réponses: 4
    Dernier message: 17/01/2006, 09h49
  5. Réponses: 68
    Dernier message: 30/11/2005, 17h29

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