C# 如何改变鼠标样式?

fkyq01 2006-08-17 09:48:51
请问:
在C#中如何改变鼠标样式?
...全文
1514 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
kkk_visual 2006-08-17
  • 打赏
  • 举报
回复
System.Windows.Forms.Cursor cur = new Cursor("c:\\mycursor.cur");
this.Cursor = cur;
fkyq01 2006-08-17
  • 打赏
  • 举报
回复
那我如果想在treeview中实现拖动鼠标改变节点顺序该怎么做啊?
guyes123 2006-08-17
  • 打赏
  • 举报
回复
学习
xiaodong_1567 2006-08-17
  • 打赏
  • 举报
回复
我大概没份了,呵呵
三省Ta叔 2006-08-17
  • 打赏
  • 举报
回复
楼上的都对
我来接分了
tangyong12 2006-08-17
  • 打赏
  • 举报
回复
楼上的正解,一般都是
Cursor = Cursors.**
后面有各种鼠标样式,最好是用try{}finally{}圈起来。否则程序出错后鼠标样式没有还原。
idda 2006-08-17
  • 打赏
  • 举报
回复
一般是这样

try {
this.Cursor = Cursors.WaitCursor;

}catch (Exception ex) {

} finally {
this.Cursor = Cursors.Default;
}
idda 2006-08-17
  • 打赏
  • 举报
回复
this.Cursor = Cursors.Default;
lovvver 2006-08-17
  • 打赏
  • 举报
回复
1.对于普通的鼠标样式(Cursors.*),可以直接设定;
2.如何改变windows提供的所有类型的鼠标呢?
Test.cs

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;

namespace ColorCursor
{
/// <summary>
/// 本例子的作用:
/// 在.NET中实现彩色光标,动画光标和自定义光标。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
[DllImport("user32.dll")]
public static extern IntPtr LoadCursorFromFile( string fileName );

[DllImport("user32.dll")]
public static extern IntPtr SetCursor( IntPtr cursorHandle );

[DllImport("user32.dll")]
public static extern uint DestroyCursor( IntPtr cursorHandle );


[STAThread]
static void Main()
{
Application.Run(new Form1());
}

public Form1()
{
this.Text = "欢迎光临【孟宪会之精彩世界】:http://dotnet.aspx.cc/";
Cursor myCursor = new Cursor(Cursor.Current.Handle);
//dinosau2.ani为windows自带的光标:
IntPtr colorCursorHandle = LoadCursorFromFile(@"C:\WINNT\Cursors\dinosau2.ani" );
myCursor.GetType().InvokeMember("handle",BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.Instance |
BindingFlags.SetField,null,myCursor,
new object [] { colorCursorHandle } );
this.Cursor = myCursor;
}
}
}
[引自【孟子E章】]
feesuo 2006-08-17
  • 打赏
  • 举报
回复
直接在控件的属性"Cursor"中选择就可以啦.
idda 2006-08-17
  • 打赏
  • 举报
回复
这个嘛,问题不难,回答蛮难.你得再DragDrop,DragLeave,DragOver里面写代码,修改你的tree的源数据,然后刷新树

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧