Link to home
Create AccountLog in
Avatar of Chris-Manginelli
Chris-Manginelli

asked on

Creating Color Dialog

I'm new to VB programming, and am watching the Teir 1 tutorial provided by Microsoft (http://msdn.microsoft.com/en-us/beginner/bb308891.aspx). I'm trying to make a button which opens a color dialog box and changes the background color of the window based off the color chosen in the dialog box. Unfortunately, even coding it exactly the way it is in the tutorial, I get debug errors.

My Errors:

Error      1      Name 'ColorDialog1' is not declared.      C:\Users\mangin\Documents\Visual Studio 2008\Projects\WindowsApplication2\WindowsApplication2\Form1.vb      3      9      WindowsApplication2

Error      2      Name 'ColorDialog1' is not declared.      C:\Users\mangin\Documents\Visual Studio 2008\Projects\WindowsApplication2\WindowsApplication2\Form1.vb      4      24      WindowsApplication2


I don't understand how the girl in the tutorial has no problems with this exact coding. Any suggestion helps.
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ColorDialog1.ShowDialog()
        Me.BackColor = ColorDialog1.Color
    End Sub
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ororiole
ororiole
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Mike Tomlinson
Or you can add a ColorDialog onto your form (instead of declaring one locally...but either way is fine!).  It's in the section of the ToolBox labled "Dialogs":

ColorDialog.jpg
Avatar of Chris-Manginelli
Chris-Manginelli

ASKER

Thank you both!