Results 1 to 6 of 6

Thread: A scrollable PictureBox in C#

  1. #1
    Join Date
    Nov 2009
    Posts
    117

    A scrollable PictureBox in C#

    Hello, I am learning C# programming and currently creating a program for the A scrollable PictureBox, but I am not able to achieve it. If you are having any solution to achieve it then please provide me code related to it. I have tried it, but I am not able to achieve it. If you are having knowledge about it, then please give me code or details of it.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: A scrollable PictureBox in C#

    Hello, if you want to create a scrollable Picturebox then the code below will provide you the scrollable picturebox. So, just make use of it.
    Code:
    public partial class testing : UserControl
    {
    private Image img = null;
    public testing()
    {
    InitializeComponent();
    this.AutoScroll = true;
    img = Bitmap.FromFile("C:\\img.jpg");
    this.AutoScrollMinSize = new Size(img.Width,img.Height);
    }
    protected override void OnPaint(PaintEventArgs e)
    {
    base.OnPaint(e);
    e.Graphics.DrawImage(img, new RectangleF(this.AutoScrollPosition.X ,this.AutoScrollPosition.Y , img.Width, img.Height));
    }
    }

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: A scrollable PictureBox in C#

    Hi, for achieving the scrollable Picturebox in c# you need to make use of the methods below:
    • PictureBoxSizeMode.Normal
    • PictureBoxSizeMode.CenterImage
    • PictureBoxSizeMode.StretchImage
    • PictureBoxSizeMode.AutoSize

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: A scrollable PictureBox in C#

    Hello, I have got the code below for making the scrollable PictureBox in C#. You can able to make use of it as per your use.
    Code:
    private void UserPictureBox_Paint(object provider, System.Windows.Forms.PaintEventArgs e)
    {
    Graphics gr = e.Graphics;
    gr.FillRectangle(Brushes.White,this.CRect);
    if (img != null)
    {
    gr.DrawImageUnscaled(img, -OffsetX, -OffsetY, img.Width, img.Height);
    gr.FillRectangle(Brushes.Blue, CRect.Width - vscroll.Width, CRect.Height - hscroll.Height, vscroll.Width, hscroll.Height);
    }
    }

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: A scrollable PictureBox in C#

    Hello, Creation of such scrollable Picturebox in C# is too much simple. You need to make use of the code below first:
    Code:
    this.panel1.AutoScroll = true;
    Now you need to add the PictureBox control in that panel and then by simply setting the SizeMode to AutoSize and by adding the code below you will able to get the what you want.
    Code:
    this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: A scrollable PictureBox in C#

    Hello, you can achieve it Using the control. It is came in the namespace PictureBoxCtrl. Overthere you will get the public class having name as PictureBox : System.Windows.Forms.UserControl. If you make use iof this control then you will able to get the following properties:
    • Picture
    • Border

Similar Threads

  1. Replies: 5
    Last Post: 05-04-2010, 11:00 AM
  2. Scrollable resultset in JAVA
    By Adrina_g in forum Software Development
    Replies: 3
    Last Post: 28-11-2009, 02:18 PM
  3. VB.Net Picturebox load jpeg file
    By Aienstaien in forum Software Development
    Replies: 3
    Last Post: 03-08-2009, 02:42 PM
  4. Drag & Drop PictureBox
    By Suzane in forum Software Development
    Replies: 2
    Last Post: 01-05-2009, 01:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,749,738,596.87828 seconds with 16 queries