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
ScrollBarRenderer.DrawArrowButton() 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

ressed; 2:Hot(Mouse Hover)
private int _UpButtonStatus = 0;
private int _DownButtonStatus = 0;
public SpinControl()
{
this._UpButton = new Button();
this._DownButton = new Button();
this._UpButton.Paint += new PaintEventHandler(UpButton_Paint);
this._DownButton.Paint += new PaintEventHandler(DownButton_Paint);
this._UpButton.MouseDown += new
MouseEventHandler(_UpButton_MouseDown);
this._UpButton.MouseUp += new MouseEventHandler(_UpButton_MouseUp);
this._DownButton.MouseDown += new
MouseEventHandler(_DownButton_MouseDown);
this._DownButton.MouseUp += new
MouseEventHandler(_DownButton_MouseUp);
this._UpButton.MouseEnter += new EventHandler(_UpButton_MouseEnter);
this._DownButton.MouseEnter += new
EventHandler(_DownButton_MouseEnter);
this._UpButton.MouseLeave += new EventHandler(_UpButton_MouseLeave);
this._DownButton.MouseLeave += new
EventHandler(_DownButton_MouseLeave);
this.AjustArrowButtonSize();
this.Controls.Add(this._UpButton);
this.Controls.Add(this._DownButton);
this.Width = 20;
}
void _UpButton_MouseLeave(object sender, EventArgs e)
{
_UpButtonStatus = 0;
}
void _UpButton_MouseUp(object sender, MouseEventArgs e)
{
_UpButtonStatus = 0;
}
void _UpButton_MouseDown(object sender, MouseEventArgs e)
{
_UpButtonStatus = 1;
}
void _UpButton_MouseEnter(object sender, EventArgs e)
{
_UpButtonStatus = 2;
}
void _DownButton_MouseUp(object sender, MouseEventArgs e)
{
_DownButtonStatus = 0;
}
void _DownButton_MouseLeave(object sender, EventArgs e)
{
_DownButtonStatus = 0;
}
void _DownButton_MouseDown(object sender, MouseEventArgs e)
{
_DownButtonStatus = 1;
}
void _DownButton_MouseEnter(object sender, EventArgs e)
{
_DownButtonStatus = 2;
}
protected override void OnResize(EventArgs e)
{
this.AjustArrowButtonSize();
base.OnResize(e);
}
private void AjustArrowButtonSize()
{
this._UpButton.Size = this.Size;
this._DownButton.Size = this.Size;
this._UpButton.Height /= 2;
this._DownButton.Height /= 2;
this._DownButton.Top = this._UpButton.Bottom;
}
void UpButton_Paint(object sender, PaintEventArgs e)
{
if (_UpButtonStatus == 0 )
{
ScrollBarRenderer.DrawArrowButton(e.Graphics,
this._UpButton.ClientRectangle,
System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.UpNormal);
}
else if (_UpButtonStatus == 1)
{
ScrollBarRenderer.DrawArrowButton(e.Graphics,
this._UpButton.ClientRectangle,
System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.UpPressed);
}
else
{
ScrollBarRenderer.DrawArrowButton(e.Graphics,
this._UpButton.ClientRectangle,
System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.UpHot);
}
}
void DownButton_Paint(object sender, PaintEventArgs e)
{
if (_DownButtonStatus == 0)
{
ScrollBarRenderer.DrawArrowButton(e.Graphics,
this._UpButton.ClientRectangle,
System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.DownNormal);
}
else if (_DownButtonStatus == 1)
{
ScrollBarRenderer.DrawArrowButton(e.Graphics,
this._UpButton.ClientRectangle,
System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.DownPressed);
}
else
{
ScrollBarRenderer.DrawArrowButton(e.Graphics,
this._UpButton.ClientRectangle,
System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.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:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#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/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.