Scrolling (AutoScrollMinSize) : Form Event : GUI Windows Form C# Source Code


Custom Search

C# Source Code » GUI Windows Form » Form Event »

 

Scrolling (AutoScrollMinSize)








    
 


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class Form1 : System.Windows.Forms.Form {
    [STAThread]
    static void Main() {
        Application.Run(new Form1());
    }
    protected override void OnPaint(PaintEventArgs e) {
        Graphics g;
        g = Graphics.FromHwnd(this.Handle);
        GraphicsUnit units = GraphicsUnit.Pixel;

        string path = "your.jpg";
        Image im = Image.FromFile(path);
        this.AutoScrollMinSize = new Size(im.Width, im.Height);
        //this.AutoScroll = true;

        Point P = this.AutoScrollPosition;
        Rectangle dstR = this.ClientRectangle;
        RectangleF srcR = new RectangleF(-P.X, -P.Y, dstR.Width, dstR.Height);
        g.DrawImage(im, dstR, srcR, units);
        g.Dispose();
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo GUI Windows Form
» Form Event