PropertyGrid.PropertySort Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém ou define o tipo de ordenação que utiliza PropertyGrid para mostrar propriedades.
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
Valor de Propriedade
Um dos PropertySort valores. O padrão é Categorized ou Alphabetical.
Exceções
O valor atribuído não é um dos PropertySort valores.
Exemplos
O seguinte exemplo de código demonstra a inicialização de um PropertyGrid controlo usando as PropertySortpropriedades , ToolbarVisible . Além disso, este exemplo define a PropertyGrid propriedade do Visible controlo para false que a grelha não seja visível quando o exemplo for executado. Para executar este exemplo, cole o seguinte código num formulário e chame o InitializePropertyGrid método do construtor do formulário ou Load método de gestão de eventos. Para visualizar a grelha de propriedades quando o formulário está a correr, altere a propriedade da Visible grelha para true, recompile e execute novamente o formulário.
// 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
Observações
Quando defines a PropertySort propriedade, a aparência dos botões de ordenação de propriedades na grelha muda para refletir o estado atual da propriedade. Definir PropertySort para PropertySort.NoSort faz com que as propriedades sejam exibidas pela ordem em que foram recuperadas.
Definir PropertySort para ambos Alphabetical e Categorized é o mesmo que definir PropertySort para Categorized sozinho. A visão categorizada é sempre apresentada em ordem alfabética.
Note
Para fazer ordenação personalizada, implemente ICustomTypeDescriptor no componente o retorno das propriedades na ordem desejada.