Help! Color Dialog cancel button still results in colour change

cygnus2112

New member
Joined
Apr 28, 2008
Messages
2
Location
uk
Programming Experience
Beginner
Hi,

for some reason when i choose to cancel a colour change the selected text still changes colour, and i think it shouldn't.

It'd be great if someone can tell me where im going wrong, heres my code

VB.NET:
    Private Sub cmdForeColour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdForeColour.Click

        Dim col1 As Color

        ColorDialog1.ShowDialog()
        col1 = ColorDialog1.Color

        If chkTextbox1.Checked Then
            txtText1.ForeColor = col1
        End If

        If chkTextbox2.Checked Then
            txtText2.ForeColor = col1
        End If

    End Sub

cheers!
 
do this instead of ColorDialog1.ShowDialog()

VB.NET:
if(colorDialog1.ShowDialog() = Windows.Forms.DialogResult.OK)
'do stuff here when okay is pressed
endif
 
Hi, thanks for the help

for some reason my original code is working on a different computer than the one i was first working on.... strange!?!

mark
 
Back
Top