VB.Net by API/System.Windows.Forms/HScrollBar — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:51, 26 мая 2010
Содержание
HScrollBar.LargeChange
imports System
imports System.Drawing
imports System.Windows.Forms
public class NumericUpDowns : inherits Form
dim hbar as HScrollBar
dim vbar as VScrollBar
dim nupdwn as NumericUpDown
public sub New()
Size = new Size(480,580)
hbar = new HScrollBar()
hbar.Parent = me
hbar.Location = new Point(0, 25)
hbar.Size = new Size(300, 25)
hbar.Minimum = 25
hbar.Maximum = 400
hbar.SmallChange = 10
hbar.LargeChange = 100
hbar.Value = 10
AddHandler hbar.ValueChanged, AddressOf hbar_OnValueChanged
vbar = new VScrollBar()
vbar.Parent = me
vbar.Location = new Point(25, 25)
vbar.Size = new Size(25, 300)
vbar.Minimum = 25
vbar.Maximum = 400
vbar.SmallChange = 10
vbar.LargeChange = 100
vbar.Value = 10
AddHandler vbar.ValueChanged, AddressOf vbar_OnValueChanged
nupdwn = new NumericUpDown()
nupdwn.Parent = me
nupdwn.Location = new Point(100,100)
nupdwn.Size = new Size(60,20)
nupdwn.Value = 1
nupdwn.Minimum = -10
nupdwn.Maximum = 10
nupdwn.Increment = .25d " decimal
nupdwn.DecimalPlaces = 2
nupdwn.ReadOnly = true
nupdwn.TextAlign = HorizontalAlignment.Right
AddHandler nupdwn.ValueChanged, AddressOf nupdwn_OnValueChanged
end sub
private sub hbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(hbar.Value)
Console.WriteLine(hbar.LargeChange)
end sub
private sub vbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(vbar.Value)
Console.WriteLine(vbar.LargeChange)
end sub
private sub nupdwn_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(nupdwn.Value)
end sub
public shared sub Main()
Application.Run(new NumericUpDowns())
end sub
end class
HScrollBar.Maximum
imports System
imports System.Drawing
imports System.Windows.Forms
public class NumericUpDowns : inherits Form
dim hbar as HScrollBar
dim vbar as VScrollBar
dim nupdwn as NumericUpDown
public sub New()
Size = new Size(480,580)
hbar = new HScrollBar()
hbar.Parent = me
hbar.Location = new Point(0, 25)
hbar.Size = new Size(300, 25)
hbar.Minimum = 25
hbar.Maximum = 400
hbar.SmallChange = 10
hbar.LargeChange = 100
hbar.Value = 10
AddHandler hbar.ValueChanged, AddressOf hbar_OnValueChanged
vbar = new VScrollBar()
vbar.Parent = me
vbar.Location = new Point(25, 25)
vbar.Size = new Size(25, 300)
vbar.Minimum = 25
vbar.Maximum = 400
vbar.SmallChange = 10
vbar.LargeChange = 100
vbar.Value = 10
AddHandler vbar.ValueChanged, AddressOf vbar_OnValueChanged
nupdwn = new NumericUpDown()
nupdwn.Parent = me
nupdwn.Location = new Point(100,100)
nupdwn.Size = new Size(60,20)
nupdwn.Value = 1
nupdwn.Minimum = -10
nupdwn.Maximum = 10
nupdwn.Increment = .25d " decimal
nupdwn.DecimalPlaces = 2
nupdwn.ReadOnly = true
nupdwn.TextAlign = HorizontalAlignment.Right
AddHandler nupdwn.ValueChanged, AddressOf nupdwn_OnValueChanged
end sub
private sub hbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(hbar.Value)
Console.WriteLine(hbar.LargeChange)
end sub
private sub vbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(vbar.Value)
Console.WriteLine(vbar.LargeChange)
end sub
private sub nupdwn_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(nupdwn.Value)
end sub
public shared sub Main()
Application.Run(new NumericUpDowns())
end sub
end class
HScrollBar.Minimum
imports System
imports System.Drawing
imports System.Windows.Forms
public class NumericUpDowns : inherits Form
dim hbar as HScrollBar
dim vbar as VScrollBar
dim nupdwn as NumericUpDown
public sub New()
Size = new Size(480,580)
hbar = new HScrollBar()
hbar.Parent = me
hbar.Location = new Point(0, 25)
hbar.Size = new Size(300, 25)
hbar.Minimum = 25
hbar.Maximum = 400
hbar.SmallChange = 10
hbar.LargeChange = 100
hbar.Value = 10
AddHandler hbar.ValueChanged, AddressOf hbar_OnValueChanged
vbar = new VScrollBar()
vbar.Parent = me
vbar.Location = new Point(25, 25)
vbar.Size = new Size(25, 300)
vbar.Minimum = 25
vbar.Maximum = 400
vbar.SmallChange = 10
vbar.LargeChange = 100
vbar.Value = 10
AddHandler vbar.ValueChanged, AddressOf vbar_OnValueChanged
nupdwn = new NumericUpDown()
nupdwn.Parent = me
nupdwn.Location = new Point(100,100)
nupdwn.Size = new Size(60,20)
nupdwn.Value = 1
nupdwn.Minimum = -10
nupdwn.Maximum = 10
nupdwn.Increment = .25d " decimal
nupdwn.DecimalPlaces = 2
nupdwn.ReadOnly = true
nupdwn.TextAlign = HorizontalAlignment.Right
AddHandler nupdwn.ValueChanged, AddressOf nupdwn_OnValueChanged
end sub
private sub hbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(hbar.Value)
Console.WriteLine(hbar.LargeChange)
end sub
private sub vbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(vbar.Value)
Console.WriteLine(vbar.LargeChange)
end sub
private sub nupdwn_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(nupdwn.Value)
end sub
public shared sub Main()
Application.Run(new NumericUpDowns())
end sub
end class
HScrollBar.Scroll
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class ScrollBarControl
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private components As System.ruponentModel.IContainer
Friend WithEvents HScrollBar1 As System.Windows.Forms.HScrollBar
Friend WithEvents VScrollBar1 As System.Windows.Forms.VScrollBar
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.HScrollBar1 = New System.Windows.Forms.HScrollBar
Me.VScrollBar1 = New System.Windows.Forms.VScrollBar
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.SuspendLayout()
"
"HScrollBar1
"
Me.HScrollBar1.Location = New System.Drawing.Point(24, 208)
Me.HScrollBar1.Name = "HScrollBar1"
Me.HScrollBar1.Size = New System.Drawing.Size(176, 16)
Me.HScrollBar1.TabIndex = 2
Me.HScrollBar1.Value = 50
"
"VScrollBar1
"
Me.VScrollBar1.LargeChange = 1
Me.VScrollBar1.Location = New System.Drawing.Point(208, 32)
Me.VScrollBar1.Maximum = 3
Me.VScrollBar1.Name = "VScrollBar1"
Me.VScrollBar1.Size = New System.Drawing.Size(16, 168)
Me.VScrollBar1.TabIndex = 3
"
"Label1
"
Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Label1.Location = New System.Drawing.Point(24, 32)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(176, 168)
Me.Label1.TabIndex = 4
Me.Label1.Text = "Visual Basic"
"
"Label2
"
Me.Label2.Location = New System.Drawing.Point(88, 240)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(56, 16)
Me.Label2.TabIndex = 5
Me.Label2.Text = "Font Size"
"
"Label3
"
Me.Label3.Location = New System.Drawing.Point(232, 48)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(48, 24)
Me.Label3.TabIndex = 6
Me.Label3.Text = "Red"
"
"Label4
"
Me.Label4.Location = New System.Drawing.Point(232, 96)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(48, 24)
Me.Label4.TabIndex = 7
Me.Label4.Text = "Yellow"
"
"Label5
"
Me.Label5.Location = New System.Drawing.Point(232, 152)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(40, 16)
Me.Label5.TabIndex = 8
Me.Label5.Text = "Green"
"
"Form1
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.VScrollBar1)
Me.Controls.Add(Me.HScrollBar1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
Label1.Font = New Font(Label1.Font.FontFamily, HScrollBar1.Value)
End Sub
Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
Select Case VScrollBar1.Value
Case 1
Label1.ForeColor = Color.Red
Case 2
Label1.ForeColor = Color.Yellow
Case 3
Label1.ForeColor = Color.Green
End Select
End Sub
End Class
HScrollBar.SmallChange
imports System
imports System.Drawing
imports System.Windows.Forms
public class NumericUpDowns : inherits Form
dim hbar as HScrollBar
dim vbar as VScrollBar
dim nupdwn as NumericUpDown
public sub New()
Size = new Size(480,580)
hbar = new HScrollBar()
hbar.Parent = me
hbar.Location = new Point(0, 25)
hbar.Size = new Size(300, 25)
hbar.Minimum = 25
hbar.Maximum = 400
hbar.SmallChange = 10
hbar.LargeChange = 100
hbar.Value = 10
AddHandler hbar.ValueChanged, AddressOf hbar_OnValueChanged
vbar = new VScrollBar()
vbar.Parent = me
vbar.Location = new Point(25, 25)
vbar.Size = new Size(25, 300)
vbar.Minimum = 25
vbar.Maximum = 400
vbar.SmallChange = 10
vbar.LargeChange = 100
vbar.Value = 10
AddHandler vbar.ValueChanged, AddressOf vbar_OnValueChanged
nupdwn = new NumericUpDown()
nupdwn.Parent = me
nupdwn.Location = new Point(100,100)
nupdwn.Size = new Size(60,20)
nupdwn.Value = 1
nupdwn.Minimum = -10
nupdwn.Maximum = 10
nupdwn.Increment = .25d " decimal
nupdwn.DecimalPlaces = 2
nupdwn.ReadOnly = true
nupdwn.TextAlign = HorizontalAlignment.Right
AddHandler nupdwn.ValueChanged, AddressOf nupdwn_OnValueChanged
end sub
private sub hbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(hbar.Value)
Console.WriteLine(hbar.LargeChange)
end sub
private sub vbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(vbar.Value)
Console.WriteLine(vbar.LargeChange)
end sub
private sub nupdwn_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(nupdwn.Value)
end sub
public shared sub Main()
Application.Run(new NumericUpDowns())
end sub
end class
HScrollBar.ValueChanged
imports System
imports System.Drawing
imports System.Windows.Forms
public class NumericUpDowns : inherits Form
dim hbar as HScrollBar
dim vbar as VScrollBar
dim nupdwn as NumericUpDown
public sub New()
Size = new Size(480,580)
hbar = new HScrollBar()
hbar.Parent = me
hbar.Location = new Point(0, 25)
hbar.Size = new Size(300, 25)
hbar.Minimum = 25
hbar.Maximum = 400
hbar.SmallChange = 10
hbar.LargeChange = 100
hbar.Value = 10
AddHandler hbar.ValueChanged, AddressOf hbar_OnValueChanged
vbar = new VScrollBar()
vbar.Parent = me
vbar.Location = new Point(25, 25)
vbar.Size = new Size(25, 300)
vbar.Minimum = 25
vbar.Maximum = 400
vbar.SmallChange = 10
vbar.LargeChange = 100
vbar.Value = 10
AddHandler vbar.ValueChanged, AddressOf vbar_OnValueChanged
nupdwn = new NumericUpDown()
nupdwn.Parent = me
nupdwn.Location = new Point(100,100)
nupdwn.Size = new Size(60,20)
nupdwn.Value = 1
nupdwn.Minimum = -10
nupdwn.Maximum = 10
nupdwn.Increment = .25d " decimal
nupdwn.DecimalPlaces = 2
nupdwn.ReadOnly = true
nupdwn.TextAlign = HorizontalAlignment.Right
AddHandler nupdwn.ValueChanged, AddressOf nupdwn_OnValueChanged
end sub
private sub hbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(hbar.Value)
Console.WriteLine(hbar.LargeChange)
end sub
private sub vbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(vbar.Value)
Console.WriteLine(vbar.LargeChange)
end sub
private sub nupdwn_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
Console.WriteLine(nupdwn.Value)
end sub
public shared sub Main()
Application.Run(new NumericUpDowns())
end sub
end class