Add Custom Control to DataGridViewCell

Posted by Kovscer on Stack Overflow See other posts from Stack Overflow or by Kovscer
Published on 2010-04-15T17:12:59Z Indexed on 2010/04/15 19:13 UTC
Read the original article Hit count: 145

Filed under:
|
|

Hello,

I create a custom control inherited from Windows.System.Forms.Controls.

This is my code of this control:

   public partial class MonthEventComponent : Control
    {
        private Color couleur;
        private Label labelEvenement;

        public MonthEventComponent(Color couleur_c, String labelEvenement_c )
        {
            InitializeComponent();
            this.couleur = couleur_c;
            this.labelEvenement.Text = labelEvenement_c;
            this.labelEvenement.ForeColor = couleur;
            this.labelEvenement.BackColor = Color.White;
            this.labelEvenement.TextAlign = ContentAlignment.MiddleLeft;
            this.labelEvenement.Dock = DockStyle.Fill;
            this.Controls.Add(labelEvenement);
        }

        public MonthEventComponent()
        {
            InitializeComponent();
            this.couleur = Color.Black;
            this.labelEvenement = new Label();
            this.labelEvenement.ForeColor = couleur;
            this.labelEvenement.BackColor = Color.White;
            this.labelEvenement.Text = "Evénement Initialiser";
            this.labelEvenement.TextAlign = ContentAlignment.MiddleLeft;
            this.labelEvenement.Dock = DockStyle.Fill;

            this.Controls.Add(labelEvenement);

        }


        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);

            MessageBox.Show("Click");
        }

    }

I would like to insert this control or multiple of this control on a DataGridViewCell but i don't know how to do this.

Thank you in advance for your answer,

Best Regards,

PS: I'm french, i'm apologize for any can of language errors.

© Stack Overflow or respective owner

Related posts about c#

Related posts about custom-controls