bjwade62 Posted February 14, 2006 Posted February 14, 2006 I have the following code in a click event. It's supposed to change the bachground color of a listview control. It works fine except when I click the cancel button in the ColorDialog control. When I do that it sets the listview color to black. Any help out there? Thanks! ColorDialog1.ShowDialog() lblLeftSide.BackColor = ColorDialog1.Color frmMain.lvwLeftList.BackColor = ColorDialog1.Color Quote
Cags Posted February 14, 2006 Posted February 14, 2006 You need to check how the user exits the ColorDialog form. Basically the following code says if the user didn't click cancel then change colours. You could also change this to say if the user did click ok by changing it to == DialogResult.Ok. If ColorDialog1.ShowDialog() <> DialogResult.Cancel Then lblLeftSide.BackColor = ColorDialog1.Color frmMain.lvwLeftList.BackColor = ColorDialog1.Color End If Quote Anybody looking for a graduate programmer (Midlands, England)?
bjwade62 Posted February 14, 2006 Author Posted February 14, 2006 That works but I have to hit cancel twice to completely dismiss the colordialog box. You need to check how the user exits the ColorDialog form. Basically the following code says if the user didn't click cancel then change colours. You could also change this to say if the user did click ok by changing it to == DialogResult.Ok. If ColorDialog1.ShowDialog() <> DialogResult.Cancel Then lblLeftSide.BackColor = ColorDialog1.Color frmMain.lvwLeftList.BackColor = ColorDialog1.Color End If Quote
Cags Posted February 14, 2006 Posted February 14, 2006 I suspect thats because you did something like this.... ColorDialog1.ShowDialog() If ColorDialog1.ShowDialog() <> DialogResult.Cancel Then lblLeftSide.BackColor = ColorDialog1.Color frmMain.lvwLeftList.BackColor = ColorDialog1.Color End If The line If ColorDialog1.ShowDialog() <> DialogResult.Cancel Then displays the dialog and checks the result so you don't have to call it seperately from that line of code. Quote Anybody looking for a graduate programmer (Midlands, England)?
bjwade62 Posted February 14, 2006 Author Posted February 14, 2006 I was just about to tell you I fixed it. That's exactly what I had. Man I hope to be as good as you someday! Thanks Again! I suspect thats because you did something like this.... ColorDialog1.ShowDialog() If ColorDialog1.ShowDialog() <> DialogResult.Cancel Then lblLeftSide.BackColor = ColorDialog1.Color frmMain.lvwLeftList.BackColor = ColorDialog1.Color End If The line If ColorDialog1.ShowDialog() <> DialogResult.Cancel Then displays the dialog and checks the result so you don't have to call it seperately from that line of code. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.