鼠标放到窗体上会变色,怎么实现 把鼠标放到窗体上,会触发窗体的 鼠标悬浮事件,想问一下,内部是怎么实现的,需要监听器吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 比如说一个label标签,有单击事件,怎样产生的单击事件,我自己做了个控件,怎么让他产生单击事件,或者是鼠标悬浮事件。谢谢接打,,,,, 这个前提是label是个控件,有单击事件,而我自己做的控件,事先并没有单击事件,我想做个单击事件,或者是鼠标悬浮事件,不知道该怎么做。 //定义事件参数public sealed class CustomEventArgs : EventArgs{ ...}// 定义委托public delegate void CustomEventHandler(object sender, CustomEventArgs e);// 创建事件public event CustomEventHandler Custom;//执行事件protected virtual void OnCustom(CustomEventArgs e){ if (Custom != null) { Custom(this, e); }}最后就是在你的代码中合适的位置执行OnCustom触发事件了 如何添加事件响应啊,就像windows控件一样,有各种各样的事件 微软的控件是怎么开发出来的,比如说label标签,按钮button 用一个Label控件,图像画在Label上,Label支持鼠标事件. 把你做的空间放DIV里 他有很多事件 <div onmouseout ="out(id)" onmouseover ="over(id)"> function over(id) { document.getElementById(id).style.backgroundColor="#99cc66"; } function out(id) { document.getElementById(id).style.backgroundColor="#99ffcc"; } 你们说的也可以,权宜之计,我想开发一个全新的控件,就像lable,button,呢样,有自己的属性,事件,该怎么做呢 Label 控件public class Label : Control{ // Fields private bool controlToolTip; private static readonly object EVENT_TEXTALIGNCHANGED = new object(); private BitVector32 labelState = new BitVector32(); private static readonly int PropImage = PropertyStore.CreateKey(); private static readonly int PropImageAlign = PropertyStore.CreateKey(); private static readonly int PropImageIndex = PropertyStore.CreateKey(); private static readonly int PropImageList = PropertyStore.CreateKey(); private static readonly int PropTextAlign = PropertyStore.CreateKey(); private int requestedHeight; private int requestedWidth; internal bool showToolTip; private static readonly BitVector32.Section StateAnimating = BitVector32.CreateSection(1, StateAutoSize); private static readonly BitVector32.Section StateAutoEllipsis = BitVector32.CreateSection(1, StateBorderStyle); private static readonly BitVector32.Section StateAutoSize = BitVector32.CreateSection(1, StateUseMnemonic); private static readonly BitVector32.Section StateBorderStyle = BitVector32.CreateSection(2, StateFlatStyle); private static readonly BitVector32.Section StateFlatStyle = BitVector32.CreateSection(3, StateAnimating); private static readonly BitVector32.Section StateUseMnemonic = BitVector32.CreateSection(1); private LayoutUtils.MeasureTextCache textMeasurementCache; private ToolTip textToolTip; // Events [EditorBrowsable(EditorBrowsableState.Always), SRCategory("CatPropertyChanged"), SRDescription("ControlOnAutoSizeChangedDescr"), Browsable(true)] public event EventHandler AutoSizeChanged { add { base.AutoSizeChanged += value; } remove { base.AutoSizeChanged -= value; } } [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public event EventHandler BackgroundImageChanged { add { base.BackgroundImageChanged += value; } remove { base.BackgroundImageChanged -= value; } } [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public event EventHandler BackgroundImageLayoutChanged { add { base.BackgroundImageLayoutChanged += value; } remove { base.BackgroundImageLayoutChanged -= value; } } [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)] public event EventHandler ImeModeChanged { add { base.ImeModeChanged += value; } remove { base.ImeModeChanged -= value; } } [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)] public event KeyEventHandler KeyDown { add { base.KeyDown += value; } remove { base.KeyDown -= value; } } [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public event KeyPressEventHandler KeyPress { add { base.KeyPress += value; } remove { base.KeyPress -= value; } } [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public event KeyEventHandler KeyUp { add { base.KeyUp += value; } remove { base.KeyUp -= value; } } [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)] public event EventHandler TabStopChanged { add { base.TabStopChanged += value; } remove { base.TabStopChanged -= value; } } [SRCategory("CatPropertyChanged"), SRDescription("LabelOnTextAlignChangedDescr")] public event EventHandler TextAlignChanged { add { base.Events.AddHandler(EVENT_TEXTALIGNCHANGED, value); } remove { base.Events.RemoveHandler(EVENT_TEXTALIGNCHANGED, value); } }…… 你可以 看下 Reflector.exe 上控件的代码 控件开发是不是要继承form窗体 求一个wince上用c#实现语音朗读的例子 web上传音频文件如何得到文件时间长度 使用SOCKET与客户端直接访问局域网内数据库的区别? EXCEL 格式控制 C# 效率问题 求 绘图时鼠标带十字线 思路 求救,获取图片 c++调用c#做的com问题 c# 网络编程的问题(非常紧急)在线等待 部署项目的问题 【送分】 100求助CollectionView的分组问题 如何使用推模式给CrystalReportViewer添加报表文件? 为什么要把全局变量在构造函数中初始化?
这个前提是label是个控件,有单击事件,而我自己做的控件,事先并没有单击事件,我想做个单击事件,或者是鼠标悬浮事件,不知道该怎么做。
public sealed class CustomEventArgs : EventArgs
{
...
}// 定义委托
public delegate void CustomEventHandler(object sender, CustomEventArgs e);// 创建事件
public event CustomEventHandler Custom;//执行事件
protected virtual void OnCustom(CustomEventArgs e)
{
if (Custom != null)
{
Custom(this, e);
}
}最后就是在你的代码中合适的位置执行OnCustom触发事件了
{
document.getElementById(id).style.backgroundColor="#99cc66";
}
function out(id)
{
document.getElementById(id).style.backgroundColor="#99ffcc";
}
你们说的也可以,权宜之计,我想开发一个全新的控件,就像lable,button,呢样,有自己的属性,事件,该怎么做呢
{
// Fields
private bool controlToolTip;
private static readonly object EVENT_TEXTALIGNCHANGED = new object();
private BitVector32 labelState = new BitVector32();
private static readonly int PropImage = PropertyStore.CreateKey();
private static readonly int PropImageAlign = PropertyStore.CreateKey();
private static readonly int PropImageIndex = PropertyStore.CreateKey();
private static readonly int PropImageList = PropertyStore.CreateKey();
private static readonly int PropTextAlign = PropertyStore.CreateKey();
private int requestedHeight;
private int requestedWidth;
internal bool showToolTip;
private static readonly BitVector32.Section StateAnimating = BitVector32.CreateSection(1, StateAutoSize);
private static readonly BitVector32.Section StateAutoEllipsis = BitVector32.CreateSection(1, StateBorderStyle);
private static readonly BitVector32.Section StateAutoSize = BitVector32.CreateSection(1, StateUseMnemonic);
private static readonly BitVector32.Section StateBorderStyle = BitVector32.CreateSection(2, StateFlatStyle);
private static readonly BitVector32.Section StateFlatStyle = BitVector32.CreateSection(3, StateAnimating);
private static readonly BitVector32.Section StateUseMnemonic = BitVector32.CreateSection(1);
private LayoutUtils.MeasureTextCache textMeasurementCache;
private ToolTip textToolTip; // Events
[EditorBrowsable(EditorBrowsableState.Always), SRCategory("CatPropertyChanged"), SRDescription("ControlOnAutoSizeChangedDescr"), Browsable(true)]
public event EventHandler AutoSizeChanged
{
add
{
base.AutoSizeChanged += value;
}
remove
{
base.AutoSizeChanged -= value;
}
} [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public event EventHandler BackgroundImageChanged
{
add
{
base.BackgroundImageChanged += value;
}
remove
{
base.BackgroundImageChanged -= value;
}
} [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public event EventHandler BackgroundImageLayoutChanged
{
add
{
base.BackgroundImageLayoutChanged += value;
}
remove
{
base.BackgroundImageLayoutChanged -= value;
}
} [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public event EventHandler ImeModeChanged
{
add
{
base.ImeModeChanged += value;
}
remove
{
base.ImeModeChanged -= value;
}
} [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public event KeyEventHandler KeyDown
{
add
{
base.KeyDown += value;
}
remove
{
base.KeyDown -= value;
}
} [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public event KeyPressEventHandler KeyPress
{
add
{
base.KeyPress += value;
}
remove
{
base.KeyPress -= value;
}
} [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public event KeyEventHandler KeyUp
{
add
{
base.KeyUp += value;
}
remove
{
base.KeyUp -= value;
}
} [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public event EventHandler TabStopChanged
{
add
{
base.TabStopChanged += value;
}
remove
{
base.TabStopChanged -= value;
}
} [SRCategory("CatPropertyChanged"), SRDescription("LabelOnTextAlignChangedDescr")]
public event EventHandler TextAlignChanged
{
add
{
base.Events.AddHandler(EVENT_TEXTALIGNCHANGED, value);
}
remove
{
base.Events.RemoveHandler(EVENT_TEXTALIGNCHANGED, value);
}
}
……