Prakash Mondal

Prakash Mondal

  • NA
  • 288
  • 210.1k

How to show dynamic label over the combobox and textbox

Mar 20 2022 10:34 AM

1. Form_Load()

2. After click the button

My code is:

private void Form3_Load(object sender, EventArgs e)
{
    ComboBox cc1 = new ComboBox();
    cc1.Location = new Point(52, 90);
    cc1.Name = "combox_123";
    cc1.Items.Add("aaaaa");
    cc1.Items.Add("bbbbbbbb");

    TextBox t = new TextBox();
    t.Location = new Point(200, 90);
    t.Name = "textBox123";
    t.Text = "Prakash";
    panel1.Controls.Add(cc1);
    panel1.Controls.Add(t);
}

private void button1_Click(object sender, EventArgs e)
{
    Label lb = new Label();
    lb.AutoSize = true;
    lb.BackColor = System.Drawing.Color.LightCoral;
    lb.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
    lb.Location = new System.Drawing.Point(47, 90);
    lb.Name = "label1";
    lb.Size = new System.Drawing.Size(339, 15);
    lb.TabIndex = 5;
    lb.Text = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

    panel1.Controls.Add(lb);
}

 


Answers (6)