1
Answer

Find Iteratively Child Controls contained by other parent controls

sachin yadav

sachin yadav

13y
1.7k
1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Control_practice1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
FindControls(this, comboBox2);
}
public void FindControls(Control control, Control FillerControl)
{
 ComboBox cb = (ComboBox)FillerControl;
for (int i = 0; i < control.Controls.Count; i++)
{
cb.Items.Add(control.Controls[i].Name);
}
}

private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox3.Items.Clear();
Control cc = new Control();
cc = Controls[comboBox2.Text];
FindControls(cc, comboBox3);
}
}
}
Answers (1)