Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:)

  • Leaders
Posted

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.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...