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

C# Discussion :

RadioButton's côte à côte dans un GroupBox


Sujet :

C#

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    263
    Détails du profil
    Informations personnelles :
    Âge : 73
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2008
    Messages : 263
    Points : 121
    Points
    121
    Par défaut RadioButton's côte à côte dans un GroupBox
    Hello,
    J'ai besoin d'afficher les deux RadioButton's de mon GroupBox côte à côte, parce qu'ils doivent prendre place dans une rangée de Button's. Comment faire ?
    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
                this.btn_ViewEdit = new GroupBox();
                this.btn_ViewEdit.Text = ".";
                this.rb_Edit = new RadioButton();
                this.rb_Edit.Text = "Edit";
                this.rb_Edit.Name = "Edit";
                this.rb_Edit.AutoSize = true;  // Width = 5;  // 
                this.rb_View.Location = new Point(this.rb_Edit.Right + 0, 0);
                this.rb_Edit.FlatStyle = FlatStyle.System;
                this.rb_View = new RadioButton();
                this.rb_View.Text = "View";
                this.rb_View.Name = "View";
                this.rb_View.AutoSize = true;  // Width = 5;  // 
                this.rb_View.Location = new Point(this.rb_Edit.Right + 8, 0);
                this.rb_View.Checked = true;
                this.btn_ViewEdit.Controls.Add(this.rb_Edit);
                this.btn_ViewEdit.Controls.Add(this.rb_View);
                this.btn_ViewEdit.TabIndex = 4;
                this.btn_ViewEdit.AutoSize = true;
                this.btn_ViewEdit.Click += new EventHandler(onBtn_ViewEdit_Click);
                this.btn_ViewEdit.Location = new Point(this.btn_Refresh.Right + 10, 0);
                this.Right_SplitPanel.Panel2.Controls.Add(this.btn_ViewEdit);
    ...
            private GroupBox btn_ViewEdit;
            public RadioButton rb_Edit;
            private RadioButton rb_View;
    Merci d'avance.

  2. #2
    Modérateur
    Avatar de sevyc64
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2007
    Messages
    10 223
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 10 223
    Points : 28 213
    Points
    28 213
    Par défaut
    Et quel est le problème dans ton code, qui, à première vue, me semble correct ?

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    263
    Détails du profil
    Informations personnelles :
    Âge : 73
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2008
    Messages : 263
    Points : 121
    Points
    121
    Par défaut
    Voir sur la photo adjointe : Des lignes à côté de chaque radioButton. Je pense qu'elles proviennent du GroupBox. Comment les supprimer ?

    [IMG]\C:\Users\cv\Pictures\Probl RadioButton SideBySide.bmp[/IMG]
    [IMG]C:\Bibliotheken\Afbeeldingen\Probl RadioButton SideBySide.bmp[/IMG]

    Zut, je pense avoir des problèmes d'uploading de mon screenshot ... A Lundi ...

    Merci sevyc64

  4. #4
    Modérateur
    Avatar de sevyc64
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2007
    Messages
    10 223
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 10 223
    Points : 28 213
    Points
    28 213
    Par défaut
    Pas d'images, donc je ne sais pas de quelles lignes tu parle.

    Peut-être s'agit-il de la bordure du GroupBox.
    Dans ce cas essaye de le remplacer par un panel, qui, par défaut n'a pas de bordure (en tout cas elle est supprimable).

  5. #5
    Expert éminent Avatar de Graffito
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    5 993
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 5 993
    Points : 7 903
    Points
    7 903
    Par défaut
    rb_Edit.Location = ???

    En C#:
    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
     
    this.rb_Edit = AddRadioButton(X,Y,"Edit",btn_ViewEdit.Controls) ;
    // X et Y en relatif par rapport à ",btn_ViewEdit.
     
    internal static RadioButton AddRadioButton(int X, int Y, String ControlText,
                                           Control.ControlCollection ParentControl)
        {
          RadioButton NewControl = new RadioButton();
          NewControl.Location = new System.Drawing.Point(X, Y);
          NewControl.Text = ControlText;
          NewControl.Size = new Size(10, 10);
          ParentControl.Add(NewControl);
          NewControl.AutoSize = true;
          return NewControl;
        }

  6. #6
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    263
    Détails du profil
    Informations personnelles :
    Âge : 73
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2008
    Messages : 263
    Points : 121
    Points
    121
    Par défaut
    Merci sevyc64 et Graffito.
    Une semaine en retard pour vous répondre --> Mes excuses.
    J'ai la solution:
    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
                // rB_Edit
                this.rb_Edit = new RadioButton();
                this.rb_Edit.AutoSize = true;
                this.rb_Edit.Location = new System.Drawing.Point(61, 13);
                this.rb_Edit.Name = "Edit";
                this.rb_Edit.Size = new System.Drawing.Size(43, 13);
                this.rb_Edit.TabIndex = 1;
                this.rb_Edit.TabStop = true;
                this.rb_Edit.Text = "Edit";
                this.rb_Edit.UseVisualStyleBackColor = true;
                // this.rb_Edit.FlatStyle = FlatStyle.System;
                // 
                // rB_View
                this.rb_View = new RadioButton();
                this.rb_View.AutoSize = true;
                this.rb_View.Location = new System.Drawing.Point(7, 13);
                this.rb_View.Name = "View";
                this.rb_View.Size = new System.Drawing.Size(48, 13);
                this.rb_View.TabIndex = 0;
                this.rb_View.TabStop = true;
                this.rb_View.Text = "View";
                this.rb_View.UseVisualStyleBackColor = true;
                this.rb_View.Checked = true;
                //
                // gB_ViewEdit
                this.gb_ViewEdit = new GroupBox();
                this.gb_ViewEdit.SuspendLayout();
                // this.gb_ViewEdit.FlatStyle = FlatStyle.System;
                this.gb_ViewEdit.Controls.Add(this.rb_Edit);
                this.gb_ViewEdit.Controls.Add(this.rb_View);
                this.gb_ViewEdit.Location = new System.Drawing.Point(this.btn_Refresh.Right + 10, -10);
                this.gb_ViewEdit.Name = "ViewEdit";
                this.gb_ViewEdit.Size = new System.Drawing.Size(100, 40);
                this.gb_ViewEdit.TabIndex = 4;
                this.gb_ViewEdit.TabStop = false;
                this.gb_ViewEdit.Text = ".";
                // 
                this.Right_SplitPanel.Panel2.Controls.Add(this.gb_ViewEdit);
                this.gb_ViewEdit.Click += new System.EventHandler(this.onRB_ViewEdit_CheckedChanged);
                this.gb_ViewEdit.ResumeLayout(false);
                this.gb_ViewEdit.PerformLayout();
                // this.ResumeLayout(false);
    Voir screenshot en pièce jointe (RadioButtons1.png).

    Mais
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    this.btn_Remove.Click += new EventHandler(onBtn_Remove_Click);
    n'appelle hélas pas encore ma fonction
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
            void onRB_ViewEdit_CheckedChanged(object sender, EventArgs e)
            {
                if (this.rb_Edit.Checked)
                {
                    this.dataGridView.EditMode = DataGridViewEditMode.EditOnEnter;
                    this.dataGridView.Focus();
                }
                else
                {
                    this.dataGridView.EditMode = DataGridViewEditMode.EditProgrammatically;
                }
            }
    Pourtant j'emploie '...Click' et 'EventHandler(...'
    Comment cela se faisse ?
    Merci d'avance.
    Images attachées Images attachées  

  7. #7
    Expert éminent sénior Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 177
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 177
    Points : 25 125
    Points
    25 125
    Par défaut
    bien content que tu ais la solution car personnellement je ne comprends toujours pas la question ...


    et sinon tu t'étonnes que pointer vers onBtn_Remove_Click ne fasse pas pointer sur onRB_ViewEdit_CheckedChanged c'est bien ca ?

Discussions similaires

  1. Logos côte à côte dans un tableau
    Par vivicente dans le forum Mise en page CSS
    Réponses: 3
    Dernier message: 18/08/2009, 13h21
  2. position d'un radioButton dans une groupBox
    Par isoman dans le forum Windows Forms
    Réponses: 5
    Dernier message: 15/12/2008, 12h15
  3. Comment savoir quel radiobutton est coché dans un groupbox
    Par valebl dans le forum Windows Forms
    Réponses: 12
    Dernier message: 09/06/2008, 19h40
  4. Réponses: 2
    Dernier message: 06/11/2006, 21h43
  5. [VB.NET]Gestion de radioButton dans une GroupBox
    Par Yeti_in dans le forum Windows Forms
    Réponses: 1
    Dernier message: 24/05/2006, 09h06

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