c# - Custom Control to use Cursor Hand -
i've made custom control in c# , anytime user's cursor hovering on custom control want cursor displayed 'hand'. place code such thing?
????.cursor = cursors.hand; in order make hand cursor being displayed when hovering on custom control?
namespace customrangebar { public partial class rangebar : usercontrol { public rangebar() { initializecomponent(); label1.forecolor = color.black; this.forecolor = systemcolors.highlight; // set default color rangebar this.click += new eventhandler(rangebar_click); } protected float percent = 0.0f; // protected because don't want accessed outside // create value property rangebar public float value { { return percent; } set { // maintain value between 0 , 100 if (value < 0) value = 0; else if (value > 100) value = 100; percent = value; label1.text = value.tostring(); //redraw rangebar every time value changes this.invalidate(); } } protected override void onpaint(painteventargs e) { base.onpaint(e); brush b = new solidbrush(this.forecolor); //create brush draw background of range bar // create linear gradient drawn on background. fromargb means can use alpha value transparency lineargradientbrush lb = new lineargradientbrush(new rectangle(0, 0, this.width, this.height), color.fromargb(255, color.white), color.fromargb(50, color.white), lineargradientmode.vertical); // calculate how has rangebar filled 'x' % int width = (int)((percent / 100) * this.width); e.graphics.fillrectangle(b, 0, 0, width, this.height); e.graphics.fillrectangle(lb, 0, 0, width, this.height); b.dispose(); lb.dispose(); } private void rangebar_sizechanged(object sender, eventargs e) { // maintain label in center of rangebar label1.location = new point(this.width / 2 - 21 / 2 - 4, this.height / 2 - 15 / 2); } } } public void rangebar_click(object obj, eventargs ea) { // executed if picturebox gets clicked label1.text = "increment 1"; }
usercontrol derives control , therefore should have cursor property inherited class. not see cursor property in code/properties?
Comments
Post a Comment