I am having problems with a Label_Paint event causing a continuous loop.
Here is an explanation of the code.
I right click on a label and a context menu pops up.
I then select a menu item named "cmLSolidColor" . Here is its code:
Private Sub cmLSolidColor_C lick(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmLSolidColor.C lick
LabelBackColorS olid()
End Sub
It calls a sub named "LabelBackColor Solid". Here is its code:
Private Sub LabelBackColorS olid()
If ColorDialog1.Sh owDialog() = DialogResult.OK Then
If bCMTrigger = True Then
If strCMTrigger = "lblP1JoyUp " Then
lblP1JoyUp.Back Color = (ColorDialog1.C olor)
ElseIf strCMTrigger = "lblP1JoyRi ght" Then
lblP1JoyRight.B ackColor = (ColorDialog1.C olor)
End if
End if
End if
End Sub
The problem is that the label I'm right clicking on has a Label_Paint event.
Execution goes to the line "LabelBackColor Solid" in the cmlSolidColor_C lick
event properly. Then It enters the Private Sub, "LabelBackColor Solid". When
it attempts to read the first line, "If ColorDialog1... " and launch the
dialog box, It immediately triggers the Label_Paint event and enter a
continuous loop. If I pause it in the debugger and then continue the loop
ends, the dialog box pops up, I pick my color, it applies it and all is
well. What can I do to stop this behavior. Is there a way to force it now to
do the Label_Paint event at this point, say, until the end of the
"LabelBackColor Solid" sub is complete?
Thank you,
John