locked
Enable or disable Image click RRS feed

  • Question

  • May I know how to enable or disable clicks on images ? Is there any codes available?

    Thanks

    Thursday, March 1, 2018 5:56 AM

Answers

  • May I know how to enable or disable clicks on images ? Is there any codes available?

    Thanks

    This is something you would do through your own code logic.  For example, you might have a Boolean flag variable that you set somewhere else in code (or use a control such as a Checkbox if the user can control the enable/disable).

    'flag to control enable/disable of clicks
    Private isPictureClickDisabled As Boolean
    
    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
        If Not isPictureClickDisabled Then
            'do something when the picture is clicked
        End If
    End Sub
    
    In this example you would presumably have some other code which sets the value of isPictureClickDisabled to control whether or not the PictureBox.Click code executes.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Thursday, March 1, 2018 1:09 PM

All replies

  • May I know how to enable or disable clicks on images ? Is there any codes available?

    Thanks

    Hi Prabaharan,

    What do you want to do? Normally we put the image in a container, like PictureBox or button or other controls, if you put image into Button, we can enable or disable it, you want to do this?

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 1, 2018 7:33 AM
  • May I know how to enable or disable clicks on images ? Is there any codes available?

    Thanks

    This is something you would do through your own code logic.  For example, you might have a Boolean flag variable that you set somewhere else in code (or use a control such as a Checkbox if the user can control the enable/disable).

    'flag to control enable/disable of clicks
    Private isPictureClickDisabled As Boolean
    
    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
        If Not isPictureClickDisabled Then
            'do something when the picture is clicked
        End If
    End Sub
    
    In this example you would presumably have some other code which sets the value of isPictureClickDisabled to control whether or not the PictureBox.Click code executes.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Thursday, March 1, 2018 1:09 PM
  • To add as well. 

    A click on an image does nothing. Windows get that click and send the message about that to the active program. That can handle it or simply do nothing with it. 

    So if you don't handle it, there is nothing to disable. 


    Success
    Cor

    Thursday, March 1, 2018 1:12 PM