ProgressBar.Minimum Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur nilai minimum rentang kontrol.
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
Nilai Properti
Nilai minimum rentang. Defaultnya adalah 0.
Pengecualian
Nilai yang ditentukan untuk properti kurang dari 0.
Contoh
Contoh kode berikut menggunakan ProgressBar kontrol untuk menampilkan kemajuan operasi penyalinan file. Contoh menggunakan Minimum properti dan Maximum untuk menentukan rentang yang ProgressBar setara dengan jumlah file yang akan disalin. Kode ini juga menggunakan Step properti dengan PerformStep metode untuk menaikkan nilai ProgressBar saat file disalin. Contoh ini mengharuskan Anda memiliki ProgressBar kontrol yang dibuat yang disebut pBar1 yang dibuat dalam Form, dan bahwa ada metode yang dibuat yang disebut CopyFile (yang mengembalikan nilai Boolean yang menunjukkan operasi penyalinan file berhasil diselesaikan) yang melakukan operasi penyalinan file. Kode ini juga mengharuskan array string yang berisi file untuk disalin dibuat dan diteruskan ke CopyWithProgress metode yang ditentukan dalam contoh, dan bahwa metode dipanggil dari metode atau peristiwa lain di Form.
private:
void CopyWithProgress( array<String^>^filenames )
{
// Display the ProgressBar control.
pBar1->Visible = true;
// Set Minimum to 1 to represent the first file being copied.
pBar1->Minimum = 1;
// Set Maximum to the total number of files to copy.
pBar1->Maximum = filenames->Length;
// Set the initial value of the ProgressBar.
pBar1->Value = 1;
// Set the Step property to a value of 1 to represent each file being copied.
pBar1->Step = 1;
// Loop through all files to copy.
for ( int x = 1; x <= filenames->Length; x++ )
{
// Copy the file and increment the ProgressBar if successful.
if ( CopyFile( filenames[ x - 1 ] ))
{
// Perform the increment on the ProgressBar.
pBar1->PerformStep();
}
}
}
private void CopyWithProgress(string[] filenames)
{
// Display the ProgressBar control.
pBar1.Visible = true;
// Set Minimum to 1 to represent the first file being copied.
pBar1.Minimum = 1;
// Set Maximum to the total number of files to copy.
pBar1.Maximum = filenames.Length;
// Set the initial value of the ProgressBar.
pBar1.Value = 1;
// Set the Step property to a value of 1 to represent each file being copied.
pBar1.Step = 1;
// Loop through all files to copy.
for (int x = 1; x <= filenames.Length; x++)
{
// Copy the file and increment the ProgressBar if successful.
if (CopyFile(filenames[x-1]))
{
// Perform the increment on the ProgressBar.
pBar1.PerformStep();
}
}
}
Private Sub CopyWithProgress(ByVal ParamArray filenames As String())
' Display the ProgressBar control.
pBar1.Visible = True
' Set Minimum to 1 to represent the first file being copied.
pBar1.Minimum = 1
' Set Maximum to the total number of files to copy.
pBar1.Maximum = filenames.Length
' Set the initial value of the ProgressBar.
pBar1.Value = 1
' Set the Step property to a value of 1 to represent each file being copied.
pBar1.Step = 1
' Loop through all files to copy.
Dim x As Integer
for x = 1 To filenames.Length - 1
' Copy the file and increment the ProgressBar if successful.
If CopyFile(filenames(x - 1)) = True Then
' Perform the increment on the ProgressBar.
pBar1.PerformStep()
End If
Next x
End Sub
Keterangan
Properti ini menentukan batas Value bawah properti. Ketika nilai Minimum properti diubah, ProgressBar kontrol digambar ulang untuk mencerminkan rentang kontrol baru. Ketika nilai Value properti sama dengan nilai Minimum properti, bilah kemajuan kosong. Untuk mengubah nilai bilah kemajuan, gunakan Step properti dengan PerformStep metode , gunakan Increment metode , atau atur nilai properti secara Value langsung.