C# 鼠标移到按钮上,在鼠标处弹出对话框 如题,就是让弹出的对话框的左上角在鼠标处 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 获取屏幕坐标 Cursor类新建一个窗体,设置StartPosition属性为Manul(记不清了,就是手动设置位置),设置窗体的Loction属性,Show下即可 你可以试下 tooltips 控件。 可以用JS函数啊,触发alert事件 ToolTip toolTip = new ToolTip(); toolTip.ShowAlways = true; toolTip.IsBalloon = true;//是否为气泡显示 toolTip.SetToolTip(btnHide, "要显示的文字");//btnHide是按钮的NAME属性, 为窗体添加事件响应,比如MouseClick,然后定义一个新的form,将其startposition设为manual,然后将其location设为e.location,即可。 winform或者silverlight程序的话,可以使用MouseEnter事件配合MouseMove事件。首先定义一个MessageForm public class MessageForm : Form { private Button btnYes; private Button btnNo; public MessageForm() { this.InitializeComponent(); } private void InitializeComponent() { this.btnYes = new System.Windows.Forms.Button(); this.btnNo = new System.Windows.Forms.Button(); this.SuspendLayout(); // // btnYes // this.btnYes.Location = new System.Drawing.Point(36, 60); this.btnYes.Name = "btnYes"; this.btnYes.Size = new System.Drawing.Size(75, 23); this.btnYes.TabIndex = 0; this.btnYes.Text = "Yes"; this.btnYes.UseVisualStyleBackColor = true; // // btnNo // this.btnNo.Location = new System.Drawing.Point(161, 60); this.btnNo.Name = "btnNo"; this.btnNo.Size = new System.Drawing.Size(75, 23); this.btnNo.TabIndex = 1; this.btnNo.Text = "No"; this.btnNo.UseVisualStyleBackColor = true; // // MessageForm // this.ClientSize = new System.Drawing.Size(274, 136); this.Controls.Add(this.btnNo); this.Controls.Add(this.btnYes); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Name = "MessageForm"; this.ResumeLayout(false); } }然后再主窗体添加如下代码 public bool IsMouseEnter { get; set; } private void btnOK_MouseEnter(object sender, EventArgs e) { this.IsMouseEnter = true; } private void btnOK_MouseMove(object sender, MouseEventArgs e) { if (this.IsMouseEnter == true) { MessageForm messageForm = new MessageForm(); messageForm.StartPosition = FormStartPosition.Manual; messageForm.Left = e.X + this.btnOK.Left+ this.Left; messageForm.Top = e.Y + this.btnOK.Top + this.Top; messageForm.FormClosed += (a, b) => { this.IsMouseEnter = false; }; messageForm.ShowDialog(); } } C#调用C++DLL 函数参数为 未知struct 老问题了,C#中显示图片问题请教! 用C#做手机游戏 对象会忘了自己的类型? 看看下面代码,运完出错"内存不足"! vs.net平台,使用c#调用borland c++6.0开发com组件 请教一个在.Net里使用XML文档注释的问题 如何刷新页面求教 MSDN2003 安装,谁有下载地址?我在Google中找到的都不行 知道哪里有关于C#的书吗? 解释一下! int 实例化的问题
新建一个窗体,设置StartPosition属性为Manul(记不清了,就是手动设置位置),设置窗体的Loction属性,Show下即可
toolTip.ShowAlways = true;
toolTip.IsBalloon = true;//是否为气泡显示
toolTip.SetToolTip(btnHide, "要显示的文字");//btnHide是按钮的NAME属性,
首先定义一个MessageForm
public class MessageForm : Form
{
private Button btnYes;
private Button btnNo; public MessageForm()
{
this.InitializeComponent();
} private void InitializeComponent()
{
this.btnYes = new System.Windows.Forms.Button();
this.btnNo = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnYes
//
this.btnYes.Location = new System.Drawing.Point(36, 60);
this.btnYes.Name = "btnYes";
this.btnYes.Size = new System.Drawing.Size(75, 23);
this.btnYes.TabIndex = 0;
this.btnYes.Text = "Yes";
this.btnYes.UseVisualStyleBackColor = true;
//
// btnNo
//
this.btnNo.Location = new System.Drawing.Point(161, 60);
this.btnNo.Name = "btnNo";
this.btnNo.Size = new System.Drawing.Size(75, 23);
this.btnNo.TabIndex = 1;
this.btnNo.Text = "No";
this.btnNo.UseVisualStyleBackColor = true;
//
// MessageForm
//
this.ClientSize = new System.Drawing.Size(274, 136);
this.Controls.Add(this.btnNo);
this.Controls.Add(this.btnYes);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "MessageForm";
this.ResumeLayout(false); }
}然后再主窗体添加如下代码
public bool IsMouseEnter { get; set; } private void btnOK_MouseEnter(object sender, EventArgs e)
{
this.IsMouseEnter = true;
} private void btnOK_MouseMove(object sender, MouseEventArgs e)
{
if (this.IsMouseEnter == true)
{
MessageForm messageForm = new MessageForm();
messageForm.StartPosition = FormStartPosition.Manual;
messageForm.Left = e.X + this.btnOK.Left+ this.Left;
messageForm.Top = e.Y + this.btnOK.Top + this.Top;
messageForm.FormClosed += (a, b) =>
{
this.IsMouseEnter = false;
};
messageForm.ShowDialog();
}
}