Scrollbar Design

  • Thread starter Thread starter Neelima Godugu
  • Start date Start date
N

Neelima Godugu

Hi All,
I am trying to implement custom scrollbars in dotnet(using C#). I am half
way through but not quiet their yet. I think I am not able to nail down the
formula for calculating the scroll width(the scrolling part). I am hoping
somebody can point me in the right direction.
Another option is to extend HSCroll and VScrollbar classes in the CF Library
to add colors to them. I was not able to find any API even to do that. Any
help in this aspect will also be appreciated.
Thanks in advance
Neelima
 
Hello, Neelima

You can look at the following sample about how to control ScrollBar's
Minimal/Maximum/LargeChange/SmallChange properties.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwindowsformsscrollbarclasslargechangetopic.asp
Basically,the value of LargeChange controls how wide the scroll width
should be.

There is no exposed method in NetCF to change the color of HScrollbar and
VScrollBar. They uses system color defined in SystemColors class. If you
want to apply your own color, you probably need to write your own
MyScrollBar control (inherit from System.Windows.Forms.Control) and
override Paint. However, I don't suggest changing ScrollBar's color to some
arbitary ones - consistancy is also important.

Hope this helps.

Thanks

Xin
 
Xin,
Thanks for the link. I have not been able to try that yet. But at first
glance, looks like it is exactly what I was looking for.
Thanks
Neelima
 
Hi Xin.
The link did not help. It shows how to use the existing scrollbar classes.
But I am building a scrollbar from scratch. I need to know how to determine
the width of the scroll thumb(slider). Appreciate your help.
Thanks
neelima
 
hi, Neelima,
I compute the size of the scroll slider as:
(the whole scrollable width) / ( (Max-Min)/LargeChange + 1 )
That is, if your control's scrollable width (the area where your slider can
move) is 120, your max value is 100, min value is 0 and the large change is
20, then the width of the slider would be 120 / ( ( 100-0 ) /20 + 1) = 120
/ (5 + 1) = 20.
The idea is that you want to make your slider's size correspond to the
value of LargeChange.
Hope this helps.
Thanks
Xin
 
Back
Top