Use ScrollBar to control the picture size : ScrollBar « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » GUI Windows Form » ScrollBarScreenshots 
Use ScrollBar to control the picture size
Use ScrollBar to control the picture size


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

public class Sizer : System.Windows.Forms.Form {
    private System.Windows.Forms.PictureBox picCritter;
    private System.Windows.Forms.HScrollBar scrSize;
    
    public static void Main(){
        Application.Run(new Sizer());
    
    public Sizer() {
        InitializeComponent();
    }
    private void InitializeComponent() {
      this.picCritter = new System.Windows.Forms.PictureBox();
      this.scrSize = new System.Windows.Forms.HScrollBar();
      this.SuspendLayout();

      this.picCritter.BackColor = System.Drawing.Color.White;
      this.picCritter.Image = new Bitmap("winter.jpg");
      this.picCritter.Location = new System.Drawing.Point(88);
      this.picCritter.Name = "picCritter";
      this.picCritter.Size = new System.Drawing.Size(4040);
      this.picCritter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
      this.picCritter.TabIndex = 0;
      this.picCritter.TabStop = false;

      this.scrSize.Location = new System.Drawing.Point(16248);
      this.scrSize.Maximum = 200;
      this.scrSize.Minimum = 50;
      this.scrSize.Name = "scrSize";
      this.scrSize.Size = new System.Drawing.Size(25616);
      this.scrSize.TabIndex = 1;
      this.scrSize.Value = 50;
      this.scrSize.Scroll += new System.Windows.Forms.ScrollEventHandler(this.scrSize_Scroll);

      this.AutoScaleBaseSize = new System.Drawing.Size(513);
      this.ClientSize = new System.Drawing.Size(292273);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {this.scrSize,
                                                                  this.picCritter});
      this.Name = "Sizer";
      this.Text = "Sizer";
      this.ResumeLayout(false);

  }

  private void scrSize_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) {
      picCritter.Size = new Size(scrSize.Value, scrSize.Value);
  }
}

           
       
Related examples in the same category
1.ScrollBars Demo ScrollBars Demo
2.VScrollBar ValueChanged
3.Scroll event
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.