views:

45

answers:

3

If I make a Visual Studio 2010 WinForms project and let the wizard add Form1. Then I add a ListBox to Form1. Then I add a form with "Project/Add Windows Form", and add a ListBox to that form (Form2). And then change in my "Program.cs" file the line Application.Run(new Form1()); for Application.Run(new Form2());, the ListBox in the Form2 looks as if it has an empty line I can select (It has a focus rectangle on the first line), but the ListBox in Form1 doesn't. How is this possible? I compared the properties of both forms and list boxes and they are identical.

I know this doesn't seem to be a big deal, but I found out this difference when trying to find the cause of another problem, coincidently related to another ListBox with an empty focus rectangle.

A: 

I figured it out. It's just because there is a Button in Form1. Something with the focus being automatically in the ListBox when there is no other control. Had nothing to do with my other problem. Would delete my question if I'd know how.

jsoldi
A: 

if you don't change the ...run(new Form1()).. to ...Form 2()).. do you have no empty line at the startup of form 1..? interessting...

.....

i just rebuild your conctruct locally... you're right.. any help..?

Schnoesel15
A: 

Check the proporties of Form1 and Form2 if they are the sames. I guess the user control into them inherits of the parrent's style.

Christophe Debove