G
Guest
Hi,
I've made a custom scrollbar which consists of three buttons and a panel. My problem is: How do I move it like a scrollbar slider? I've tried DoDragDrop, but it does not appear to be the same, all though I can move the button. I have also used the mouseMove event, so I can move the button, but it's completely out of control. Still I feel it's the right way to go. This is what I've written:
private void btnSecond_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (MouseButtons.Left == e.Button)
{
btnSecond.Top = e.Y;
PositionToValue(btnSecond.Top);
}
}
private int PositionToValue(int pos)
{
return (_maxValue / (panelArea.Height-btnSecond.Height)) * pos;
}
Anyone who can help me out?
Thanks, gmtongar
I've made a custom scrollbar which consists of three buttons and a panel. My problem is: How do I move it like a scrollbar slider? I've tried DoDragDrop, but it does not appear to be the same, all though I can move the button. I have also used the mouseMove event, so I can move the button, but it's completely out of control. Still I feel it's the right way to go. This is what I've written:
private void btnSecond_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (MouseButtons.Left == e.Button)
{
btnSecond.Top = e.Y;
PositionToValue(btnSecond.Top);
}
}
private int PositionToValue(int pos)
{
return (_maxValue / (panelArea.Height-btnSecond.Height)) * pos;
}
Anyone who can help me out?
Thanks, gmtongar