Click here to Skip to main content
12,294,775 members (59,707 online)
Click here to Skip to main content

Stats

77.6K views
7.4K downloads
49 bookmarked
Posted

A Zoomable and Scrollable PictureBox

, 31 May 2008 CPOL
An ImagePanel component created to replace the PictureBox.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace YLScsImage
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void imagePanel1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Bitmap b = new Bitmap(openFileDialog1.FileName);
               //imagePanel1.CanvasSize = b.Size;
                imagePanel1.Image = b;
            }
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            imagePanel1.Zoom = trackBar1.Value * 0.02f;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

YLS CS
Unknown
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160525.2 | Last Updated 31 May 2008
Article Copyright 2008 by YLS CS
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid