[RESOLVED] [2005] ADding Buttons Dynamically
I am creating some buttons dynamically, that get added to a panel with a white background. But when I do this the buttons color becomes flat white (or what ever the background color of the panel is). If I set the flat style to System I get the standard look back, but then I can't have an image on the button (which I need). The only way I figured out how to get the button to show normal is to create a panel as the same size of the button and the button to that then that panel to the other panel. Is there any other way?
I've attached a screen shot to show the problem. Then button the left is created dynamically. The one on the right is doen through the GUI.
Here's the code I used for that screen shot.
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim btn As New Button
btn.Text = "test"
btn.Location = New Point(3, 3)
btn.BackColor = Me.BackColor
Panel1.Controls.Add(btn)
End Sub
Re: [2005] ADding Buttons Dynamically
Never mind right when I posted I thought to go look at what the gui adds. To make it look the same I have to set UseVisualStyleBackColor to true.