Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)qq
published in(发表于) 2014/7/11 9:19:32
C#中定义鼠标指针形状的方法实例

C#中定义鼠标指针形状的方法实例|方法

定义鼠标指针形状

在Windows应用程序中,通过设置控件的Cursor属性可以定义鼠标指针的显示形状。控件(如Button控件)的Cursor属性用于设置鼠标指针的类型,默认值为Default。

语法:

public virtual Cursor Cursor { get; set; }

属性值:一个Cursor,表示当鼠标指针位于控件上时显示的光标。

Cursor:是一个值,该属性值如表1所示。

表1 Cursor属性的值



示例

设置控件的Cursor属性值

本示例将Windows窗体上的各个Button按钮的Cursor属性值设置为不同的值。Button控件的属性设置如图1所示,示例运行结果如图2所示。



图1 设置属性值



图2 示例运行结果

完整程序代码如下:

★ ★★★★frmMousePointer.cs窗体代码文件完整程序代码网站源代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _2_01

{

public partial class frmMousePointer : Form

{

public frmMousePointer()

{

InitializeComponent();

}

private void frmMousePointer_Load(object sender, EventArgs e)

{

}

private void frmMousePointer_Load_1(object sender, EventArgs e)

{

}

}

}

★ ★★★★frmMousePointer.Designer.cs窗体设计文件完整程序代码★★★★★

namespace _2_01

{

partial class frmMousePointer

{

///



/// 必需的设计器变量。

///


private System.ComponentModel.IContainer components = null;

///

/// 清理所有正在使用的资源。

///


/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{//本教程来自:http://www.isstudy.com

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

///


private void InitializeComponent()

{

this.button1 = new System.Windows.Forms.Button();

this.button2 = new System.Windows.Forms.Button();

this.button3 = new System.Windows.Forms.Button();

this.button4 = new System.Windows.Forms.Button();

this.button5 = new System.Windows.Forms.Button();

this.button6 = new System.Windows.Forms.Button();

this.button7 = new System.Windows.Forms.Button();

this.button8 = new System.Windows.Forms.Button();

this.button9 = new System.Windows.Forms.Button();

this.button10 = new System.Windows.Forms.Button();

this.button11 = new System.Windows.Forms.Button();

this.button12 = new System.Windows.Forms.Button();

this.button13 = new System.Windows.Forms.Button();

this.button14 = new System.Windows.Forms.Button();

this.button15 = new System.Windows.Forms.Button();

this.button16 = new System.Windows.Forms.Button();

this.button17 = new System.Windows.Forms.Button();

this.button18 = new System.Windows.Forms.Button();

this.button22 = new System.Windows.Forms.Button();

this.button23 = new System.Windows.Forms.Button();

this.button24 = new System.Windows.Forms.Button();

this.button25 = new System.Windows.Forms.Button();

this.button26 = new System.Windows.Forms.Button();

this.button27 = new System.Windows.Forms.Button();

this.button28 = new System.Windows.Forms.Button();

this.SuspendLayout();

//

// button1

//

this.button1.Cursor = System.Windows.Forms.Cursors.Hand;

this.button1.Location = new System.Drawing.Point(12, 12);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(75, 23);

this.button1.TabIndex = 0;

this.button1.Text = "Hand";

this.button1.UseVisualStyleBackColor = true;


If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759