Mouse--Wheel event

Source: Internet
Author: User

     requires a local amplification function, that is, like Google Maps, scrolling the wheel of the mouse, the map will scale, and you can use the mouse to drag the screen to see the different parts of the larger picture.
1 for scaling, each control has one property size, and modifying the Size property enables the control to scale. In particular, most controls have MouseWheel events that register to the event with a scalable action such as a change to the Size property.
     2) Drag-and-drop function to set the AutoScroll property of the control's parent container to true, meaning that if the page is larger than the current page, a scroll property like the browser will appear.
     3) Other: How to distinguish the sliding direction of the wheel (up or down), MouseWheel event, the corresponding event parameter type is MouseEventArgs, MouseEventArgs has a Delta attribute in this event that indicates the degree to which the wheel scrolls, if the direction of the regular wheel is pushed forward (away from you, that is, you say "up"), otherwise dial backwards (near you, that is, you say "downward"), see the following code.

Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;

Using System.Windows.Forms; Namespace form Scaling {public partial class Form1:form {public Form1 () {Initializecompon
            ENT (); (Control).
            MouseWheel + = new MouseEventHandler (Form1_mousewheel); Button1.
        MouseWheel + = new MouseEventHandler (Button1_mousewheel);
                } void Button1_mousewheel (object sender, MouseEventArgs e) {try { if (button1.
                        Bounds.contains (e.location)) {if ( > 0) { Button1. size = new Size (button1. Size.width + 1, button1.
                    Size.Height + 1); else if ( < 0) {button1. size = new Size (button1. Size.width-1, button1. Size.heIGHT-1);
            catch {MessageBox.Show ("Error");
                } void Form1_mousewheel (object sender, MouseEventArgs e) {try { if (btn.
                        Bounds.contains (e.location)) {if ( > 0) { Btn. size = new Size (btn. Size.width + 1, btn.
                    Size.Height + 1); else if ( < 0) {btn. size = new Size (btn. Size.width-1, BTN.
            catch {MessageBox.Show ("Error"); }


Click Button1, and slide the mouse wheel up, to enlarge;
Place the cursor on the Button3, slide the mouse wheel up, get larger, down, shrink;
1) WinForm Automatic telescopic control xpandercontrols
2 C # mouse wheel Event
3 C # to make a scalable personalized form
4 C # with the wheel, click the button to achieve the picture zoom in and out to move

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.