ADO DOT NET Posted February 14, 2007 Posted February 14, 2007 Hi, I just wanna check if my check box on form is checked then enable a button in my safe thread. If SaveCheckBox.Checked = True Then SaveButton.Enabled = True But could not implement this. Delegate Sub SetFocusCallback() Private Sub SetFocus() If Me.SaveCheckBox.InvokeRequired Then Dim d As New SetFocusCallback(AddressOf Enabled) Me.Invoke(d, New Object() {Enabled}) Else If Me.SaveCheckBox.Checked = True Then SaveButton.Enabled = True End If End Sub It won't work! :( Anyone can help me? Thank you a lot and God bless you:) Quote
Leaders snarfblam Posted February 14, 2007 Leaders Posted February 14, 2007 I think it should look like this: [Color=Blue]Delegate Sub[/Color] SetFocusCallback() [Color=Blue]Private Sub[/Color] SetFocus() [Color=Blue]If Me[/Color].SaveCheckBox.InvokeRequired [Color=Blue]Then[/Color] [Color=Green]'Make a cross-thread "recursive call"[/Color] [Color=Blue]Dim [/Color]d As [Color=Blue]New [/Color]SetFocusCallback([Color=Blue]AddressOf [/Color]SetFocus) [Color=Blue]Me[/Color].Invoke(d) [Color=Blue]Else[/Color] [Color=Blue]If [/Color]Me.SaveCheckBox.Checked = [Color=Blue]True Then [/Color]SaveButton.Enabled = [Color=Blue]True[/Color] [Color=Green]'Could also probably be written[/Color] SaveButton.Enabled = [Color=Blue]Me[/Color].SaveCheckBox.Checked [Color=Blue] End If End Sub[/Color] [/Code] It's not tested, but I think that's the idea. Quote [sIGPIC]e[/sIGPIC]
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.