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.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.