There is string array contains some file location.
I am using a foreach loop, in which each loop i want to create a new radio button control. without foreach code performs, but in loop only one control is adding.
Can anybody tell me why? and how I perform this.
Code:
string[] location =
{
@"C:\Program Files\Skype\Phone\Skype.exe",
@"C:\Program Files\iTunes\iTunes.exe",
@"C:\Program Files\Internet Explorer\iexplore.exe"
};
int i = 10;
foreach (string path in location)
{
if (File.Exists(path))
{
RadioButton rbList = new RadioButton();
rbList.AutoSize = false;
Icon icn;
icn = Icon.ExtractAssociatedIcon(path);
rbList.Image = icn.ToBitmap();
rbList.Height = 100;
rbList.Width = 50;
i = i + 30;
rbList.Location = new Point(100, i);
groupBox1.Controls.Add(rbList);
}
}