Passing Autumn

The same 3 years, and some people from students to as the MVP, and I was in place, then the code to show off the autumn wind, a little sad, a little cool!

Bulletin
Content is very powerful ~ ~ ~ ~ ~ ~ Do not look outside the invasion not as sharp and brother, I felt kind of sense of loss ~ ~ ~

C# Winform为图片设置手势光标

今天开发“微博粉丝精灵”的魔法广告,遇到1个小的常见问题,比如图片的广告如果设置光标手势和点击问题。

由于图片直接固定了大小,不能在外面套一个LinkLable来加链接,因此简单的从另一个侧面来小小解决这个问题,当然太久没折腾winform,连设置光标都忘了,只好小小百度了一下

最后的解决方法是:为PictureBox控件增加三个事件,鼠标移进事件,鼠标移出事件,和鼠标点击事件,来共同完成原本linkLable应有的问题。

代码如下,So Easy的事:

 private void pbImg_MouseHover(object sender, EventArgs e)
        {
            this.Cursor = Cursors.Hand;
        }

        private void pbImg_MouseLeave(object sender, EventArgs e)
        {
            this.Cursor = Cursors.Default;
        }

        private void pbImg_Click(object sender, EventArgs e)
        {
            lnkTitle_LinkClicked(null, null);
        }

设置光标就一行代码,然后在点击时,引发文字上的链接事件即可。

魔法广告的效果图:

 

Autumn Park is QBlog the official site, created by the passing autumn, based on the framework data layers developed cyqdata support multi-user, multi-language, multi-database (access, mssql, oracle), directory level url and other powerful blog system
新浪微博粉丝精灵,刷粉丝、刷评论、刷转发、企业商家微博营销必备工具"

2011/12/15 0:13:48 | C# Winform基础 | |

#1微博粉丝精灵2011/12/19 16:32:41
其实把图片的Cursor属性设置为hand即可。
  • Post Comment