Hello all, I have made a small example program to illustrate my problem. The program consist of one form with one TableLayoutPanel: tableLayoutPanel1 one NumericUpDown: coins and one Button: flip. When flip is pressed the tableLayoutPanel1 is dynamically filled with coins.Value rows. Each row consist of one ComboBox with the items "Heads" and "Tails". One of these items are selected by drawing a random number for each row. The code is as follows:
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void draw_Click(object sender, EventArgs e)
{
tableLayoutPanel1.Controls.Clear();
string[] results = { "Heads", "Tails" };
int nCoins = Convert.ToInt32(coins.Value);
Random random = new Random();
for(int i = 0; i < nCoins; i++) {
ComboBox coin = new ComboBox();
coin.Items.AddRange(results);
coin.SelectedIndex = random.Next(0, 2);
tableLayoutPanel1.Controls.Add(coin, 0, i);
}
}
}
}
My problem is that the selected item in each ComboBox has focus, i.e. is blue. How do I stop this from happening? I have tried calling coin.SelectionLength = 0; but this does not work :-(.
Thaks in advance for any answers!