Results 1 to 2 of 2

Thread: [RESOLVED] [2005] ADding Buttons Dynamically

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Resolved [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:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim btn As New Button
    3.         btn.Text = "test"
    4.         btn.Location = New Point(3, 3)
    5.         btn.BackColor = Me.BackColor
    6.         Panel1.Controls.Add(btn)
    7.     End Sub
    Last edited by mpdeglau; May 4th, 2006 at 10:32 AM.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    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.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width