Csharp/C Sharp by API/System.Windows.Forms/ScrollEventType — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 15:10, 26 мая 2010
ScrollEventType.LargeDecrement
<source lang="csharp"> using System; using System.Drawing; using System.Collections; using System.ruponentModel; using System.Windows.Forms; using System.Data;
public class ScrollBars : System.Windows.Forms.Form { private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.VScrollBar vScrollBar1; int counter=0; private System.Windows.Forms.Label label1; public ScrollBars() { this.textBox1 = new System.Windows.Forms.TextBox(); this.vScrollBar1 = new System.Windows.Forms.VScrollBar(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); 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(24, 56); this.textBox1.Multiline = true; this.textBox1.Size = new System.Drawing.Size(144, 32); this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.vScrollBar1.Location = new System.Drawing.Point(168, 56); this.vScrollBar1.Name = "vScrollBar1"; this.vScrollBar1.Size = new System.Drawing.Size(16, 32); this.vScrollBar1.TabIndex = 7; this.vScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScrollBar1_Scroll); this.label1.Location = new System.Drawing.Point(8, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(192, 16); this.label1.TabIndex = 6; this.label1.Text = "Numeric Scolling using VScroll Bars"; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(208, 109); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.label1, this.vScrollBar1, this.textBox1}); this.Text = "Numeric Scroll"; this.Load += new System.EventHandler(this.ScrollBars_Load); this.ResumeLayout(false); } 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) { vScrollBar1.Maximum = 100; vScrollBar1.Minimum = 0 ; vScrollBar1.SmallChange = 1; } private void vScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) { if ( e.Type == ScrollEventType.Last ) counter = 100 ; else if ( e.Type == ScrollEventType.First) counter = 0 ; else if ( e.Type == ScrollEventType.SmallDecrement ) counter -- ; else if ( e.Type == ScrollEventType.SmallIncrement ) { counter++; MessageBox.Show("Small increment"); } else if ( e.Type == ScrollEventType.LargeDecrement ) counter-=5; else if ( e.Type == ScrollEventType.LargeIncrement ) { MessageBox.Show("Large increment"); counter+=5; } else if ( e.Type == ScrollEventType.First ) counter = 0 ; else if ( e.Type == ScrollEventType.Last) counter = 100 ; Console.WriteLine(e.NewValue+"\n"); if ( counter > 100 ) counter = 100 ; if ( counter < 0 ) counter = 0 ; textBox1.Text = counter.ToString() ; } } </source>
ScrollEventType.Last
<source lang="csharp"> using System; using System.Drawing; using System.Collections; using System.ruponentModel; using System.Windows.Forms; using System.Data;
public class ScrollBars : System.Windows.Forms.Form { private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.VScrollBar vScrollBar1; int counter=0; private System.Windows.Forms.Label label1; public ScrollBars() { this.textBox1 = new System.Windows.Forms.TextBox(); this.vScrollBar1 = new System.Windows.Forms.VScrollBar(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); 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(24, 56); this.textBox1.Multiline = true; this.textBox1.Size = new System.Drawing.Size(144, 32); this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.vScrollBar1.Location = new System.Drawing.Point(168, 56); this.vScrollBar1.Name = "vScrollBar1"; this.vScrollBar1.Size = new System.Drawing.Size(16, 32); this.vScrollBar1.TabIndex = 7; this.vScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScrollBar1_Scroll); this.label1.Location = new System.Drawing.Point(8, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(192, 16); this.label1.TabIndex = 6; this.label1.Text = "Numeric Scolling using VScroll Bars"; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(208, 109); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.label1, this.vScrollBar1, this.textBox1}); this.Text = "Numeric Scroll"; this.Load += new System.EventHandler(this.ScrollBars_Load); this.ResumeLayout(false); } 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) { vScrollBar1.Maximum = 100; vScrollBar1.Minimum = 0 ; vScrollBar1.SmallChange = 1; } private void vScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) { if ( e.Type == ScrollEventType.Last ) counter = 100 ; else if ( e.Type == ScrollEventType.First) counter = 0 ; else if ( e.Type == ScrollEventType.SmallDecrement ) counter -- ; else if ( e.Type == ScrollEventType.SmallIncrement ) { counter++; MessageBox.Show("Small increment"); } else if ( e.Type == ScrollEventType.LargeDecrement ) counter-=5; else if ( e.Type == ScrollEventType.LargeIncrement ) { MessageBox.Show("Large increment"); counter+=5; } else if ( e.Type == ScrollEventType.First ) counter = 0 ; else if ( e.Type == ScrollEventType.Last) counter = 100 ; Console.WriteLine(e.NewValue+"\n"); if ( counter > 100 ) counter = 100 ; if ( counter < 0 ) counter = 0 ; textBox1.Text = counter.ToString() ; } } </source>
ScrollEventType.SmallDecrement
<source lang="csharp"> using System; using System.Drawing; using System.Collections; using System.ruponentModel; using System.Windows.Forms; using System.Data;
public class ScrollBars : System.Windows.Forms.Form { private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.VScrollBar vScrollBar1; int counter=0; private System.Windows.Forms.Label label1; public ScrollBars() { this.textBox1 = new System.Windows.Forms.TextBox(); this.vScrollBar1 = new System.Windows.Forms.VScrollBar(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); 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(24, 56); this.textBox1.Multiline = true; this.textBox1.Size = new System.Drawing.Size(144, 32); this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.vScrollBar1.Location = new System.Drawing.Point(168, 56); this.vScrollBar1.Name = "vScrollBar1"; this.vScrollBar1.Size = new System.Drawing.Size(16, 32); this.vScrollBar1.TabIndex = 7; this.vScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScrollBar1_Scroll); this.label1.Location = new System.Drawing.Point(8, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(192, 16); this.label1.TabIndex = 6; this.label1.Text = "Numeric Scolling using VScroll Bars"; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(208, 109); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.label1, this.vScrollBar1, this.textBox1}); this.Text = "Numeric Scroll"; this.Load += new System.EventHandler(this.ScrollBars_Load); this.ResumeLayout(false); } 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) { vScrollBar1.Maximum = 100; vScrollBar1.Minimum = 0 ; vScrollBar1.SmallChange = 1; } private void vScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) { if ( e.Type == ScrollEventType.Last ) counter = 100 ; else if ( e.Type == ScrollEventType.First) counter = 0 ; else if ( e.Type == ScrollEventType.SmallDecrement ) counter -- ; else if ( e.Type == ScrollEventType.SmallIncrement ) { counter++; MessageBox.Show("Small increment"); } else if ( e.Type == ScrollEventType.LargeDecrement ) counter-=5; else if ( e.Type == ScrollEventType.LargeIncrement ) { MessageBox.Show("Large increment"); counter+=5; } else if ( e.Type == ScrollEventType.First ) counter = 0 ; else if ( e.Type == ScrollEventType.Last) counter = 100 ; Console.WriteLine(e.NewValue+"\n"); if ( counter > 100 ) counter = 100 ; if ( counter < 0 ) counter = 0 ; textBox1.Text = counter.ToString() ; } } </source>