Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft einen Wert ab, der angibt, wie die Teilstriche auf der Trackleiste angezeigt werden, oder legt diesen fest.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Property TickStyle As TickStyle
'Usage
Dim instance As TrackBar
Dim value As TickStyle
value = instance.TickStyle
instance.TickStyle = value
public TickStyle TickStyle { get; set; }
public:
property TickStyle TickStyle {
TickStyle get ();
void set (TickStyle value);
}
/** @property */
public TickStyle get_TickStyle ()
/** @property */
public void set_TickStyle (TickStyle value)
public function get TickStyle () : TickStyle
public function set TickStyle (value : TickStyle)
Eigenschaftenwert
Einer der TickStyle-Werte. Der Standardwert ist TickStyle.BottomRight.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
Der zugewiesene Wert ist kein gültiges TickStyle. |
Hinweise
Mit der TickStyle-Eigenschaft können Sie die Anzeigeart der Teilstriche auf der Trackleiste ändern.
Beispiel
Im folgenden Codebeispiel wird die Verwendung der Eigenschaften TickStyle, Minimum und Maximum sowie das Behandeln des ValueChanged-Ereignisses veranschaulicht. Zum Ausführen des Beispiels fügen Sie den folgenden Code in ein Formular ein, das ein TrackBar-Steuerelement mit dem Namen TrackBar1 und ein TextBox-Steuerelement mit dem Namen TextBox1 enthält. Rufen Sie die InitializeTrackBar-Methode aus dem Konstruktor oder der Load-Ereignisbehandlungsmethode des Formulars auf.
'Declare a new TrackBar object.
Friend WithEvents TrackBar1 As System.Windows.Forms.TrackBar
' Initalize the TrackBar and add it to the form.
Private Sub InitializeTrackBar()
Me.TrackBar1 = New System.Windows.Forms.TrackBar
' Set the TickStyle property so there are ticks on both sides
' of the TrackBar.
TrackBar1.TickStyle = TickStyle.Both
' Set the minimum and maximum number of ticks.
TrackBar1.Minimum = 10
TrackBar1.Maximum = 100
' Set the tick frequency to one tick every ten units.
TrackBar1.TickFrequency = 10
TrackBar1.Location = New System.Drawing.Point(75, 30)
Me.Controls.Add(Me.TrackBar1)
End Sub
' Handle the TrackBar.ValueChanged event by calculating a value for
' TextBox1 based on the TrackBar value.
Private Sub TrackBar1_ValueChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles TrackBar1.ValueChanged
TextBox1.Text = System.Math.Round(TrackBar1.Value / 10)
End Sub
//Declare a new TrackBar object.
internal System.Windows.Forms.TrackBar TrackBar1;
// Initalize the TrackBar and add it to the form.
private void InitializeTrackBar()
{
this.TrackBar1 = new System.Windows.Forms.TrackBar();
TrackBar1.Location = new System.Drawing.Point(75, 30);
// Set the TickStyle property so there are ticks on both sides
// of the TrackBar.
TrackBar1.TickStyle = TickStyle.Both;
// Set the minimum and maximum number of ticks.
TrackBar1.Minimum = 10;
TrackBar1.Maximum = 100;
// Set the tick frequency to one tick every ten units.
TrackBar1.TickFrequency = 10;
// Associate the event-handling method with the
// ValueChanged event.
TrackBar1.ValueChanged +=
new System.EventHandler(TrackBar1_ValueChanged);
this.Controls.Add(this.TrackBar1);
}
// Handle the TrackBar.ValueChanged event by calculating a value for
// TextBox1 based on the TrackBar value.
private void TrackBar1_ValueChanged(object sender, System.EventArgs e)
{
TextBox1.Text = (System.Math.Round(TrackBar1.Value/10.0)).ToString();
}
//Declare a new TrackBar object.
internal:
System::Windows::Forms::TrackBar^ TrackBar1;
// Initalize the TrackBar and add it to the form.
private:
void InitializeTrackBar()
{
this->TrackBar1 = gcnew System::Windows::Forms::TrackBar;
TrackBar1->Location = System::Drawing::Point( 75, 30 );
// Set the TickStyle property so there are ticks on both sides
// of the TrackBar.
TrackBar1->TickStyle = TickStyle::Both;
// Set the minimum and maximum number of ticks.
TrackBar1->Minimum = 10;
TrackBar1->Maximum = 100;
// Set the tick frequency to one tick every ten units.
TrackBar1->TickFrequency = 10;
// Associate the event-handling method with the
// ValueChanged event.
TrackBar1->ValueChanged += gcnew System::EventHandler( this, &Form1::TrackBar1_ValueChanged );
this->Controls->Add( this->TrackBar1 );
}
// Handle the TrackBar.ValueChanged event by calculating a value for
// TextBox1 based on the TrackBar value.
void TrackBar1_ValueChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
TextBox1->Text = (System::Math::Round( TrackBar1->Value / 10.0 )).ToString();
}
//Declare a new TrackBar object.
System.Windows.Forms.TrackBar trackBar1;
// Initalize the TrackBar and add it to the form.
private void InitializeTrackBar()
{
this.trackBar1 = new System.Windows.Forms.TrackBar();
trackBar1.set_Location(new System.Drawing.Point(75, 30));
// Set the TickStyle property so there are ticks on both sides
// of the TrackBar.
trackBar1.set_TickStyle(TickStyle.Both);
// Set the minimum and maximum number of ticks.
trackBar1.set_Minimum(10);
trackBar1.set_Maximum(100);
// Set the tick frequency to one tick every ten units.
trackBar1.set_TickFrequency(10);
// Associate the event-handling method with the
// ValueChanged event.
trackBar1.add_ValueChanged(new System.EventHandler(
trackBar1_ValueChanged));
this.get_Controls().Add(this.trackBar1);
} //InitializeTrackBar
// Handle the TrackBar.ValueChanged event by calculating a value for
// textBox1 based on the TrackBar value.
private void trackBar1_ValueChanged(Object sender, System.EventArgs e)
{
textBox1.set_Text(((System.Double)System.Math.Round(
trackBar1.get_Value() / 10.0)).ToString());
} //trackBar1_ValueChanged
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0
Siehe auch
Referenz
TrackBar-Klasse
TrackBar-Member
System.Windows.Forms-Namespace
TickStyle-Enumeration