Results 1 to 6 of 6

Thread: check box as indicator

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    in my app, i've got a check box placed on a command button. the command button displays/hides a large text box used for entering/editing client notes. if there are already notes, the check box is checked, if the notes are empty, there will be no check

    all of this works fine, but I want to stop the check box from being changed when it's clicked on. i came up with the following sub: -

    Public Sub CheckBoxClick(Ctrl As Control)
    'stop a check box responding to being clicked on
    With Ctrl
    If .Value = 1 Then
    .Value = 0
    Else
    .Value = 1
    End If
    End With
    End Sub

    and in the click event of the check box, i put : -

    Private Sub chk_Notes_Click()
    CheckBoxClick chk_Notes
    End Sub

    the reason i did it this way is that i have lots of occasions where i have check boxes used simply as indicators

    the only problem being when i call the sub, i get runtime error 28 - out of stack space. the only reason i can think of is that when i set the value of the check box, the click event is being called ad infinitum.

    i've tried disabling the check box, but they look horrible then.
    what's the best way of doing this - it doesnt have to be a check box on the button, as long as it looks obvious that there are or are not notes to be viewed.


    [Edited by Jimbob on 07-14-2000 at 06:15 AM]

  2. #2
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565

    Thumbs up

    This will stop a check box changing when you click on it.

    Code:
    Private intState As Integer
    
    Private Sub CheckBox_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
      intState = CheckBox.Value
    End Sub
    
    Private Sub CheckBox_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
      CheckBox.Value = intState
    End Sub

  3. #3
    Addicted Member
    Join Date
    Jul 2000
    Location
    Scotland
    Posts
    184
    Could you not change the Caption or Colours of the button at run-time? ie:

    if (notes_exist) then
    button.caption = "XXXX (Notes)"
    button.background or font = red

    else
    button.caption = "XXXX"
    button.background or font = normal
    end if

    Not proper code, but might give you the gist...

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    cheers, both of you - plenty of ideas now!

    ps, stevie

    this may be a stupid question, but how did you indent your block of code, every time i paste it in, it all aligns to the left margin

  5. #5
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    Place code and /code around your code.

    Both need square brackets around them.

  6. #6
    Guest
    Click here to see a list of all the vBulletin tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width