user control scroll

  • Thread starter Thread starter edi sol
  • Start date Start date
E

edi sol

Hi,

I am writing a hex edit control from a UserControl. I use drawtext
method of the graphics object in the OnPaint. When the text which I
draw go out of the visible rectangle of the control I want to create
scrollbars but they don't appear - I set autoscroll to true and
autoscrollmargin to (5,5).
If I add a button or other controls the scrollbars are working.

What can I do and what is my mistake?

Thanks.
 
edi,

Yes, this is the way how the build-in scrolling works in windows forms. The
control is a container and it scrolls its content (the controls it contains)
e.g. If a child control doesn't fit the scrolling area it shows up scroll
bars, so one can scroll to see all the controls.

The idea of implementing scrolling in windows forms is to add a child
control (e.g. panel ) to the scrollable control and use this panel as a
drawing canvas. When you need more space just resize the panel and the
container will adjust the scroll bars accordingly.

If you want to implement the type of scrolling you are after you need to use
scrollbar controls and implement your own logic of invalidation and redraw.

I also sometime miss the old Win32 scolling API.


HTH
Stoitcho Goutsev (100) [C# MVP]
 
Back
Top