Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# Forms: Capture scroll event in a usercontrol with only static checkboxes.

C# Forms: Capture scroll event in a usercontrol with only static checkboxes.

Scheduled Pinned Locked Moved C#
questioncsharphardwarehelp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    willempipi
    wrote on last edited by
    #1

    Hi, I have made a C# forms application. In there i use a usercontrol that dynamicly puts a list of checkboxes onto the usercontrol. Next to the checkboxes is a scrollbar. If you move the scrollbar the checkboxes will be set onto the selection that is pointed out by the scrollbar. So the Text and Checked state of the checkboxes get updated to the position in the entire list. (in short, i've made my own ListBox with checkboxes) My problem is that i cannot capture the scroll event of the mouse from checkboxes(using the hardware scrollbutton). The scroll event of the usercontrol itself doesn't get triggerd because of the checkboxes are on top of it. And the checkboxes itself do not have a scroll event. How can i solve this? Greetz Willem

    H 1 Reply Last reply
    0
    • W willempipi

      Hi, I have made a C# forms application. In there i use a usercontrol that dynamicly puts a list of checkboxes onto the usercontrol. Next to the checkboxes is a scrollbar. If you move the scrollbar the checkboxes will be set onto the selection that is pointed out by the scrollbar. So the Text and Checked state of the checkboxes get updated to the position in the entire list. (in short, i've made my own ListBox with checkboxes) My problem is that i cannot capture the scroll event of the mouse from checkboxes(using the hardware scrollbutton). The scroll event of the usercontrol itself doesn't get triggerd because of the checkboxes are on top of it. And the checkboxes itself do not have a scroll event. How can i solve this? Greetz Willem

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      If I have interpreted your question correctly, you are saying that using the scrollwheel on your mouse does not cause the panel to scroll. If I have misunderstood then please disregard the rest of this message. There are several controls in Visual Studio that suffer from this problem. Sometimes, but not always, this is caused because the control does not have focus. The solution in those cases is to handle the MouseEnter event to give the control focus.

      private void myUserControl_MouseEnter(object sender, EventArgs e)
      {
      myUserControl.Focus(); //allows the mouse wheel to work after the panel has had the mouse move over it
      }

      If this doesn't work immediately, then I am probably wrong about the cause. Good luck! :)

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” Why do programmers often confuse Halloween and Christmas? Because 31 Oct = 25 Dec.

      W 1 Reply Last reply
      0
      • H Henry Minute

        If I have interpreted your question correctly, you are saying that using the scrollwheel on your mouse does not cause the panel to scroll. If I have misunderstood then please disregard the rest of this message. There are several controls in Visual Studio that suffer from this problem. Sometimes, but not always, this is caused because the control does not have focus. The solution in those cases is to handle the MouseEnter event to give the control focus.

        private void myUserControl_MouseEnter(object sender, EventArgs e)
        {
        myUserControl.Focus(); //allows the mouse wheel to work after the panel has had the mouse move over it
        }

        If this doesn't work immediately, then I am probably wrong about the cause. Good luck! :)

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” Why do programmers often confuse Halloween and Christmas? Because 31 Oct = 25 Dec.

        W Offline
        W Offline
        willempipi
        wrote on last edited by
        #3

        This was my first solution and it doesn't work. When i do this my usercontrol will get the focus(the mouseenter event gets fired), but it doesn't fire the scroll event after that. I think this is because the checkboxes override the foces when hovering over it, I think this because the checkbox "lights up" when you hover over it(I use windows 7). So i think you understood my question right, but the solution doesn't work.

        H 1 Reply Last reply
        0
        • W willempipi

          This was my first solution and it doesn't work. When i do this my usercontrol will get the focus(the mouseenter event gets fired), but it doesn't fire the scroll event after that. I think this is because the checkboxes override the foces when hovering over it, I think this because the checkbox "lights up" when you hover over it(I use windows 7). So i think you understood my question right, but the solution doesn't work.

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          OK. Sorry. :( Keep trying though. BTW: I assume that you are aware the there is a built in CheckedListBox Control?

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” Why do programmers often confuse Halloween and Christmas? Because 31 Oct = 25 Dec.

          W 1 Reply Last reply
          0
          • H Henry Minute

            OK. Sorry. :( Keep trying though. BTW: I assume that you are aware the there is a built in CheckedListBox Control?

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” Why do programmers often confuse Halloween and Christmas? Because 31 Oct = 25 Dec.

            W Offline
            W Offline
            willempipi
            wrote on last edited by
            #5

            Well acually, i did not know that;) (kinda new in .NET Forms, the last forms application was Visual C++ 6, MFC) But there is a sophisticated system behind the interaction between the checkboxes in the list, if i want to convert that to a listcontrol it would take me some time, while the listbox i created now works exactly like i want, with the minor problem of scrolling. I also want to know how to properly solve this issue for future usage. Converting would be my last hope;)

            L 1 Reply Last reply
            0
            • W willempipi

              Well acually, i did not know that;) (kinda new in .NET Forms, the last forms application was Visual C++ 6, MFC) But there is a sophisticated system behind the interaction between the checkboxes in the list, if i want to convert that to a listcontrol it would take me some time, while the listbox i created now works exactly like i want, with the minor problem of scrolling. I also want to know how to properly solve this issue for future usage. Converting would be my last hope;)

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Maybe what it takes is you also executing Henry's myUserControl.Focus(); every time your mouse wheel actions cause the checkbox states to change. Whether you also do it after a manual checkbox state change (a click) is up to you. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


              I only read formatted code with indentation, so please use PRE tags for code snippets.


              I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


              W 1 Reply Last reply
              0
              • L Luc Pattyn

                Maybe what it takes is you also executing Henry's myUserControl.Focus(); every time your mouse wheel actions cause the checkbox states to change. Whether you also do it after a manual checkbox state change (a click) is up to you. :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                I only read formatted code with indentation, so please use PRE tags for code snippets.


                I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


                W Offline
                W Offline
                willempipi
                wrote on last edited by
                #7

                This also doesn't work... The checkbox mouseenter event gets triggerd, sets the focus to the usercontrol, but no scroll event is triggerd after that.

                L 1 Reply Last reply
                0
                • W willempipi

                  This also doesn't work... The checkbox mouseenter event gets triggerd, sets the focus to the usercontrol, but no scroll event is triggerd after that.

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  then I don't have the answer. :|

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                  I only read formatted code with indentation, so please use PRE tags for code snippets.


                  I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups