Hello Stewart,
Thank you for using Microsoft Managed Newsgroup Service, my name is Zhi-Xin
Ye, it's my pleasure to work with you on this issue.
You can create an UserControl, put two buttons in it, one on the top and
the other on the bottom. Handle the Paint event of the buttons and use
ScrollBarRender er.DrawArrowBut ton() method to draw arrows on the buttons.
For example:
========= Sample code for your information ==============
public class SpinControl : UserControl
{
private Button _UpButton;
private Button _DownButton;
//Button status 0:Normal, 1:Pressed; 2:Hot(Mouse Hover)
private int _UpButtonStatus = 0;
private int _DownButtonStat us = 0;
public SpinControl()
{
this._UpButton = new Button();
this._DownButto n = new Button();
this._UpButton. Paint += new PaintEventHandl er(UpButton_Pai nt);
this._DownButto n.Paint += new PaintEventHandl er(DownButton_P aint);
this._UpButton. MouseDown += new
MouseEventHandl er(_UpButton_Mo useDown);
this._UpButton. MouseUp += new MouseEventHandl er(_UpButton_Mo useUp);
this._DownButto n.MouseDown += new
MouseEventHandl er(_DownButton_ MouseDown);
this._DownButto n.MouseUp += new
MouseEventHandl er(_DownButton_ MouseUp);
this._UpButton. MouseEnter += new EventHandler(_U pButton_MouseEn ter);
this._DownButto n.MouseEnter += new
EventHandler(_D ownButton_Mouse Enter);
this._UpButton. MouseLeave += new EventHandler(_U pButton_MouseLe ave);
this._DownButto n.MouseLeave += new
EventHandler(_D ownButton_Mouse Leave);
this.AjustArrow ButtonSize();
this.Controls.A dd(this._UpButt on);
this.Controls.A dd(this._DownBu tton);
this.Width = 20;
}
void _UpButton_Mouse Leave(object sender, EventArgs e)
{
_UpButtonStatus = 0;
}
void _UpButton_Mouse Up(object sender, MouseEventArgs e)
{
_UpButtonStatus = 0;
}
void _UpButton_Mouse Down(object sender, MouseEventArgs e)
{
_UpButtonStatus = 1;
}
void _UpButton_Mouse Enter(object sender, EventArgs e)
{
_UpButtonStatus = 2;
}
void _DownButton_Mou seUp(object sender, MouseEventArgs e)
{
_DownButtonStat us = 0;
}
void _DownButton_Mou seLeave(object sender, EventArgs e)
{
_DownButtonStat us = 0;
}
void _DownButton_Mou seDown(object sender, MouseEventArgs e)
{
_DownButtonStat us = 1;
}
void _DownButton_Mou seEnter(object sender, EventArgs e)
{
_DownButtonStat us = 2;
}
protected override void OnResize(EventA rgs e)
{
this.AjustArrow ButtonSize();
base.OnResize(e );
}
private void AjustArrowButto nSize()
{
this._UpButton. Size = this.Size;
this._DownButto n.Size = this.Size;
this._UpButton. Height /= 2;
this._DownButto n.Height /= 2;
this._DownButto n.Top = this._UpButton. Bottom;
}
void UpButton_Paint( object sender, PaintEventArgs e)
{
if (_UpButtonStatu s == 0 )
{
ScrollBarRender er.DrawArrowBut ton(e.Graphics,
this._UpButton. ClientRectangle ,
System.Windows. Forms.VisualSty les.ScrollBarAr rowButtonState. UpNormal);
}
else if (_UpButtonStatu s == 1)
{
ScrollBarRender er.DrawArrowBut ton(e.Graphics,
this._UpButton. ClientRectangle ,
System.Windows. Forms.VisualSty les.ScrollBarAr rowButtonState. UpPressed);
}
else
{
ScrollBarRender er.DrawArrowBut ton(e.Graphics,
this._UpButton. ClientRectangle ,
System.Windows. Forms.VisualSty les.ScrollBarAr rowButtonState. UpHot);
}
}
void DownButton_Pain t(object sender, PaintEventArgs e)
{
if (_DownButtonSta tus == 0)
{
ScrollBarRender er.DrawArrowBut ton(e.Graphics,
this._UpButton. ClientRectangle ,
System.Windows. Forms.VisualSty les.ScrollBarAr rowButtonState. DownNormal);
}
else if (_DownButtonSta tus == 1)
{
ScrollBarRender er.DrawArrowBut ton(e.Graphics,
this._UpButton. ClientRectangle ,
System.Windows. Forms.VisualSty les.ScrollBarAr rowButtonState. DownPressed);
}
else
{
ScrollBarRender er.DrawArrowBut ton(e.Graphics,
this._UpButton. ClientRectangle ,
System.Windows. Forms.VisualSty les.ScrollBarAr rowButtonState. DownHot);
}
}
}
=============== ============
If you have any questions or concerns, please feel free to let me know.
Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.
Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.