Yuvraj Jambhle

Yuvraj Jambhle

  • NA
  • 93
  • 7.5k

How to read sql data to runtime added combobox in c# winforms

Nov 1 2020 11:00 AM
Hello Friends,
 
I want to read table data in dynamically added combo boxes.
 
 
 
Actually like besides the image I am adding combo boxes in runtime using button click. if I want 2 more combo box then I will add in runtime using button click.
 
My problem is how to read SQL server data in these runtime added combo boxes. I know SQL connection method.
 
But I am unable to read SQL table data for runtime added combo box.
 
using the below method I have added runtime combo boxes.
  1. int cmbFieldColm_1Count = 1;  
  2. public System.Windows.Forms.ComboBox AddComboFieldColumnP1()  
  3. {  
  4. System.Windows.Forms.ComboBox cmbBxFieldColm = new System.Windows.Forms.ComboBox();  
  5. panel1.Controls.Add(cmbBxFieldColm);  
  6. cmbBxFieldColm.Top = cmbFieldColm_1Count * 22;  
  7. cmbBxFieldColm.Left = 301;  
  8. cmbBxFieldColm.Width = 160;  
  9. cmbBxFieldColm.Name = "cmbSelectColumn" + this.cmbFieldColm_1Count.ToString();  
  10. cmbFieldColm_1Count = cmbFieldColm_1Count + 1;  
  11. return cmbBxFieldColm;  
  12. }  
Please help me.
Thanks in advance.

Answers (1)