TrackBar.Minimum Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene o establece el límite inferior del intervalo con el que trabaja este control TrackBar.
public:
property int Minimum { int get(); void set(int value); };
public int Minimum { get; set; }
member this.Minimum : int with get, set
Public Property Minimum As Integer
Valor de propiedad
Valor mínimo del control TrackBar. El valor predeterminado es 0.
Ejemplos
En el ejemplo de código siguiente se muestra cómo usar los TickFrequencymiembros , Minimumy Maximum y cómo controlar el ValueChanged evento. Para ejecutar el ejemplo, pegue el código siguiente en un formulario que contenga un TrackBar control denominado TrackBar1
y un TextBox control denominado TextBox1
. Llame al método desde el InitializeTrackBar
constructor Load o el método de control de eventos del formulario.
//Declare a new TrackBar object.
internal:
System::Windows::Forms::TrackBar^ TrackBar1;
// Initialize 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.
internal System.Windows.Forms.TrackBar TrackBar1;
// Initialize 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.
Friend WithEvents TrackBar1 As System.Windows.Forms.TrackBar
' Initialize 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
Comentarios
Puede usar el SetRange método para establecer las Maximum propiedades y Minimum al mismo tiempo.