Custom control: adding scrollbars

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gerben van Loon

    #1

    Custom control: adding scrollbars

    Hi,

    I've drawn my own control using GDI+. But the control is bigger than a
    normal form could display, so I want to add scrollbars. Saw somewhere that
    you have to inherit from "System.Windows .Forms.Scrollab leControl". So I did
    that, and the scrollbars are displayed very nice. But when you actually
    start scrolling the graphics I've drawn with GDI+ are completely disturbed.

    Someone know what I'm doing wrong? Is there another way to add scrollbars to
    a custom control?

    cheers,

    Gerben


  • Gerben van Loon

    #2
    Re: Custom control: adding scrollbars

    Already solved it by adding this code on the onpaint event:

    //Adjust the scroll position
    Matrix m = new Matrix();
    m.Translate(thi s.AutoScrollPos ition.X,this.Au toScrollPositio n.Y,MatrixOrder .
    Append);
    pe.Graphics.Tra nsform=m;

    Thank to Bob Powell (http://www.bobpowell.net/gdiplus_faq.htm)

    greets

    "Gerben van Loon" <gerbenvl@home. nl> wrote in message
    news:bfgukt$2ad $1@news3.tilbu1 .nb.home.nl...[color=blue]
    > Hi,
    >
    > I've drawn my own control using GDI+. But the control is bigger than a
    > normal form could display, so I want to add scrollbars. Saw somewhere that
    > you have to inherit from "System.Windows .Forms.Scrollab leControl". So I[/color]
    did[color=blue]
    > that, and the scrollbars are displayed very nice. But when you actually
    > start scrolling the graphics I've drawn with GDI+ are completely[/color]
    disturbed.[color=blue]
    >
    > Someone know what I'm doing wrong? Is there another way to add scrollbars[/color]
    to[color=blue]
    > a custom control?
    >
    > cheers,
    >
    > Gerben
    >
    >[/color]


    Comment

    Working...