ScrollBars Demo : 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 
ScrollBars Demo
ScrollBars Demo

/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury, 
   Zach Greenvoss, Shripad Kulkarni, Neil Whitlow

Publisher: Peer Information
ISBN: 1861007663
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace ScrollBars
{
    /// <summary>
    /// Summary description for ScrollBars.
    /// </summary>
    public class ScrollBars : System.Windows.Forms.Form
    {
        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.VScrollBar vScrollBar1;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        int counter=0;
        private System.Windows.Forms.Label label1;
        private System.ComponentModel.Container components = null;

        public ScrollBars()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Disposebool disposing )
        {
            ifdisposing )
            {
                if (components != null
                {
                    components.Dispose();
                }
            }
            base.Disposedisposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
            this.label1 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // textBox1
            // 
            this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif"12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.textBox1.ForeColor = System.Drawing.Color.Transparent;
            this.textBox1.Location = new System.Drawing.Point(2456);
            this.textBox1.Multiline = true;
            this.textBox1.Name = "textBox1";
            this.textBox1.ReadOnly = true;
            this.textBox1.Size = new System.Drawing.Size(14432);
            this.textBox1.TabIndex = 4;
            this.textBox1.Text = "";
            this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // vScrollBar1
            // 
            this.vScrollBar1.Location = new System.Drawing.Point(16856);
            this.vScrollBar1.Name = "vScrollBar1";
            this.vScrollBar1.Size = new System.Drawing.Size(1632);
            this.vScrollBar1.TabIndex = 7;
            this.vScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScrollBar1_Scroll);
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(816);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(19216);
            this.label1.TabIndex = 6;
            this.label1.Text = "Numeric Scolling using VScroll Bars";
            // 
            // ScrollBars
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(513);
            this.ClientSize = new System.Drawing.Size(208109);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.label1,
                                                                          this.vScrollBar1,
                                                                          this.textBox1});
            this.Name = "ScrollBars";
            this.Text = "Numeric Scroll";
            this.Load += new System.EventHandler(this.ScrollBars_Load);
            this.ResumeLayout(false);

        }
        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() 
        {
            Application.Run(new ScrollBars());
        }

        private void textBox1_TextChanged(object sender, System.EventArgs e)
        {
        }

        private void ScrollBars_Load(object sender, System.EventArgs e)
        {
            // Set the maximum range for the scrollbar
            vScrollBar1.Maximum = 100;
            // Set the minimum range for the scrollbar
            vScrollBar1.Minimum = 

            // Set the SmallChange factor
            vScrollBar1.SmallChange = 1;    

        }

        private void vScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
        {
            // Check if the increment is Small 
         if e.Type == ScrollEventType.Last 
            counter = 100  
         else
            // Check if the scroll is moved to minimum pos
            if e.Type == ScrollEventType.First
            counter = 0  
         else
            // Check if the scroll is moved small distance
            if e.Type == ScrollEventType.SmallDecrement 
            counter -- ; 
         else
            // Check if the scroll is moved small distance
            if e.Type == ScrollEventType.SmallIncrement )
         {
            counter++;
            MessageBox.Show("Small increment");
         }
         else
            // Check if the scroll is moved large distance
            if e.Type == ScrollEventType.LargeDecrement 
            counter-=5;
         else
            // Check if the scroll is moved large distance
            if e.Type == ScrollEventType.LargeIncrement )
         {
            MessageBox.Show("Large increment");
            counter+=5;
         }
         else
            // Check if the scroll is moved to the Min position
            if e.Type == ScrollEventType.First 
            counter = 
         else
            // Check if the scroll to the Max position
            if e.Type == ScrollEventType.Last
            counter = 100  

        Console.WriteLine(e.NewValue+"\n");
        // Check if the scroll is moved large distance
            if counter > 100 counter = 100 
            if counter < counter = ;

            textBox1.Text = counter.ToString() ;
        }
    }
}


           
       
Related examples in the same category
1.Use ScrollBar to control the picture sizeUse ScrollBar to control the picture size
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.