c# .net forms controls help

Soldato
Joined
18 Oct 2002
Posts
7,139
Location
Ironing
2 questions:

1) How do I get a textbox to select it's containing text when it becomes active?

2) why, when I've applied a theme to windows to make my widgets look like:



do my .net buttons look like:



?
 
1) you need to write something in the 'Enter' event of the textbox...

tbTextBox.SelectAll(); -- that should work.

not sure about the second question but i think you might have to explicitly state what the button looks like in the onpaint event.
 
Code:
static void Main()
{
   Application.EnableVisualStyles();
   Application.SetCompatibleTextRenderingDefault(false);            
   Application.Run(new Form1());
}

The EnableVisualStyles() should do it...

(mind you that is put in by the designer on all my projects so I'd have thought you'd already have that...)
 
I've put Application.EnableVisualStyles(); in the main form before Application.Run();, but it's still looking exactly as it was before. I don't know if it makes a difference that the form with the buttons on is a different one to the startup form?
 
Doubt it because you are running it in the same AppContext so it should inherit any properties you set.

I'll have a look later, see if i can get styles to work...
 
growse said:
2) why, when I've applied a theme to windows to make my widgets look like:



do my .net buttons look like:



?

Have you set the FlatStyle of all the controls on your form to FlatStyle.System?
This, in addition to Application.EnableVisualStyles() will do the job, nothing else is needed :)
 
Back
Top Bottom