PropertyGrid.PropertySort 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 jenis pengurutan penggunaan PropertyGrid untuk menampilkan properti.
public:
property System::Windows::Forms::PropertySort PropertySort { System::Windows::Forms::PropertySort get(); void set(System::Windows::Forms::PropertySort value); };
public System.Windows.Forms.PropertySort PropertySort { get; set; }
member this.PropertySort : System.Windows.Forms.PropertySort with get, set
Public Property PropertySort As PropertySort
Nilai Properti
Salah PropertySort satu nilai. Defaultnya adalah Categorized atau Alphabetical.
Pengecualian
Nilai yang ditetapkan bukan salah PropertySort satu nilai.
Contoh
Contoh kode berikut menunjukkan inisialisasi PropertyGrid kontrol menggunakan PropertySortproperti , ToolbarVisible . Selain itu, contoh ini mengatur PropertyGrid properti kontrol Visible ke false
sehingga kisi tidak akan terlihat saat contoh dijalankan. Untuk menjalankan contoh ini, tempelkan kode berikut dalam formulir dan panggil InitializePropertyGrid
metode dari konstruktor formulir atau Load metode penanganan peristiwa. Untuk melihat kisi properti saat formulir berjalan, ubah properti kisi Visible menjadi true
, kompilasi ulang, dan jalankan ulang formulir.
// Declare a propertyGrid.
internal:
PropertyGrid^ propertyGrid1;
private:
// Initialize propertyGrid1.
[PermissionSetAttribute(SecurityAction::Demand, Name="FullTrust")]
void InitializePropertyGrid()
{
propertyGrid1 = gcnew PropertyGrid;
propertyGrid1->Name = "PropertyGrid1";
propertyGrid1->Location = System::Drawing::Point( 185, 20 );
propertyGrid1->Size = System::Drawing::Size( 150, 300 );
propertyGrid1->TabIndex = 5;
// Set the sort to alphabetical and set Toolbar visible
// to false, so the user cannot change the sort.
propertyGrid1->PropertySort = PropertySort::Alphabetical;
propertyGrid1->ToolbarVisible = false;
propertyGrid1->Text = "Property Grid";
// Add the PropertyGrid to the form, but set its
// visibility to False so it will not appear when the form loads.
propertyGrid1->Visible = false;
this->Controls->Add( propertyGrid1 );
}
// Declare a propertyGrid.
internal PropertyGrid propertyGrid1;
// Initialize propertyGrid1.
private void InitializePropertyGrid()
{
propertyGrid1 = new PropertyGrid();
propertyGrid1.Name = "PropertyGrid1";
propertyGrid1.Location = new System.Drawing.Point(185, 20);
propertyGrid1.Size = new System.Drawing.Size(150, 300);
propertyGrid1.TabIndex = 5;
// Set the sort to alphabetical and set Toolbar visible
// to false, so the user cannot change the sort.
propertyGrid1.PropertySort = PropertySort.Alphabetical;
propertyGrid1.ToolbarVisible = false;
propertyGrid1.Text = "Property Grid";
// Add the PropertyGrid to the form, but set its
// visibility to False so it will not appear when the form loads.
propertyGrid1.Visible = false;
this.Controls.Add(propertyGrid1);
}
'Declare a propertyGrid.
Friend WithEvents propertyGrid1 As PropertyGrid
'Initialize propertyGrid1.
Private Sub InitializePropertyGrid()
propertyGrid1 = New PropertyGrid
propertyGrid1.Name = "PropertyGrid1"
propertyGrid1.Location = New Point(185, 20)
propertyGrid1.Size = New System.Drawing.Size(150, 300)
propertyGrid1.TabIndex = 5
'Set the sort to alphabetical and set Toolbar visible
'to false, so the user cannot change the sort.
propertyGrid1.PropertySort = PropertySort.Alphabetical
propertyGrid1.ToolbarVisible = False
propertyGrid1.Text = "Property Grid"
' Add the PropertyGrid to the form, but set its
' visibility to False so it will not appear when the form loads.
propertyGrid1.Visible = False
Me.Controls.Add(propertyGrid1)
End Sub
Keterangan
Saat Anda mengatur PropertySort properti , tampilan tombol pengurutan properti pada kisi berubah untuk mencerminkan status properti saat ini. Pengaturan PropertySort ke PropertySort.NoSort menyebabkan properti ditampilkan dalam urutan pengambilannya.
Pengaturan PropertySort ke keduanya Alphabetical dan Categorized sama dengan pengaturan PropertySort ke Categorized sendiri. Tampilan yang dikategorikan selalu ditampilkan sebagai alfabet.
Catatan
Untuk melakukan pengurutan kustom, terapkan ICustomTypeDescriptor pada komponen untuk mengembalikan properti dalam urutan yang diinginkan.