anjan kant

anjan kant

  • NA
  • 60
  • 0

Runtime Controls not firing in Windows Application c#

Jul 15 2014 9:42 AM
Hello,
I am using Windows application to create controls at run time but events not firing properly.

When I click on one combo box, all combo boxes values changes immediately.

Code Snippet:

private void PopulateControlsInPanel(DataTable _dt, int iTotalCon = 0)
{
iTotalCon = 6;
counter += 1;


if (counter == 1)
{
_location_Y += iHeight + 25;
}
else
{
_location_Y += iHeight + 2;
}

// button
ComboBox _com = new ComboBox();
_com.Name = "Combox" + counter;
_com.Text = "Combox" + counter;
_com.Location = new Point(80, _location_Y);
_com.DataSource = _dt;
_com.DisplayMember = "Col_Value";
_com.ValueMember = "Col_Value";
// end drop down

// lablel
Label _lab = new Label();
_lab.Name = "Lablel" + counter;
_lab.Text = "Select From " + counter;
_lab.Location = new Point(10, _location_Y);
//
iTotHeight += _location_Y;
//
pln.Controls.Add(_com);
pln.Controls.Add(_lab);
_com.SelectedIndexChanged += new System.EventHandler(this.btn_SelectedIndexChanged);
//}
}
 
Please provide your suggestions.
Thanks,

Answers (4)