c# winform鼠标相关onmouseup,onmousedown,onmousemove,onmousewhell

protected override void OnMouseUp(MouseEventArgs e)
         {
             string x = "this is\n"+
                        "a good man\n"+
                        "we must use a mouse wheel";

           //分析:三段式,在while中引用的变量要在while外面定义
             //nindex与nlines用于while之中
             int nindex = 0;
             int nlines = 0;

             //indexof(要查找到字符,开始查找的位置)
             while((nindex=x.IndexOf('\n',nindex))!=-1)
             {
                 nindex++;//累加,在字符串中当前换行符的位置,经分析,这是查找到当前换行符的下个位置,当前换行符的位置是nindex,而此处是nindex++,这样就可以在字符串中一直推进查多少到多少行了
                 nlines++;//累加,计算字符串到底有多少行

             }
         }
         //滚动鼠标滑轮时
         protected override void OnMouseWheel(MouseEventArgs e)
         {
             base.OnMouseWheel(e);
         }

         //移动鼠标
         protected override void OnMouseMove(MouseEventArgs e) //mouseeventargs提示鼠标相关的信息,如x,y分别表示鼠标的水平及垂直位置
         {
             base.OnMouseMove(e);
         }
请使用浏览器的分享功能分享到微信等