Skilled Programming

ADO DOT NET

Centurion
Joined
Dec 20, 2006
Messages
160
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.
Visual Basic:
    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:)
 
I think it should look like this:
Code:
[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]
It's not tested, but I think that's the idea.
 
Back
Top