Question: I'm creating a settings form that is quite similar to the Visual Studio 2008 "Connect To Database" form in the Server Explorer. 

The settings form is opened as a modal dialog from the parent form as follows:

```
    private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
    {
        var SettingsForm = new frmSettings();
        SettingsForm.ShowDialog(this); 
    }

```

On the SettingsForm, I have a ComboBox that will populate its list with the SQLServer instance names available on the network through the following code in the DropDown event:

```
    private void cboTrackingServerName_DropDown(object sender, EventArgs e)
    {
        DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
        if (dt.Rows.Count > 0)
        {
            cboTrackingServerName.Items.Clear();

            foreach (DataRow row in dt.Rows)
            {
                cboTrackingServerName.Items.Add(
                     row["Server"] + "\\" + row["Instance"]);
            }
        }
    }

```

The problem is that whenever the user clicks the DropDown arrow on the ComboBox, the SettingsForm loses focus to its parent form for a quick second, the SettingsForm appears to redraw itself, and then the SettingsForm regains focus. This also causes the actual DropDown list not to appear until the user clicks it again.

Any helpful thoughts on the matter?

Answer: 
Visual Studio comes with something like style #2 as the default, so that's what almost *all* C# code uses, in my experience. However, the braces in your example are indented for no obvious reason. More typical is:

```
private void Test()
{
    foreach (int x in bar)
    {
        Console.WriteLine(x);
    }
}

```

However, you can go into the Tools / Options / Languages / C# / Formatting and change it however you like. ReSharper gives even more options. Then you can reformat the code in your chosen style.
At the end of the day this is a personal preference... there are a few things to be sure of though:

1. Be consistent, not just through a file but through an entire project.
2. If you are working on a project with an existing code style then you should use that coding style yourself.
3. You may not get to choose your coding style, depending on the project. Be flexible.