DataGridColumnStyle.PropertyDescriptorChanged Evento
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Si verifica quando il valore della proprietà PropertyDescriptor cambia.
public:
event EventHandler ^ PropertyDescriptorChanged;
[System.ComponentModel.Browsable(false)]
public event EventHandler PropertyDescriptorChanged;
[<System.ComponentModel.Browsable(false)>]
member this.PropertyDescriptorChanged : EventHandler
Public Custom Event PropertyDescriptorChanged As EventHandler
Tipo evento
- Attributi
Esempio
Nell'esempio di codice seguente viene illustrato l'uso di questo membro.
private:
void myButton_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
if ( TablesAlreadyAdded )
{
return;
}
AddCustomDataTableStyle();
}
void AddCustomDataTableStyle()
{
DataGridTableStyle^ myTableStyle = gcnew DataGridTableStyle;
// Map DataGridTableStyle to a DataTable.
myTableStyle->MappingName = "Orders";
// Get CurrencyManager object.
CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(BindingContext[myDataSet, "Orders"]);
// Use the CurrencyManager to get the PropertyDescriptor for column.
PropertyDescriptor^ myPropertyDescriptor = myCurrencyManager->GetItemProperties()[ "Amount" ];
// Construct a 'DataGridColumnStyle' object changing its format to 'Currency'.
DataGridColumnStyle^ myColumnStyle = gcnew DataGridTextBoxColumn( myPropertyDescriptor,"c",true );
// Add EventHandler function for PropertyDescriptorChanged Event.
myColumnStyle->PropertyDescriptorChanged += gcnew System::EventHandler( this, &myDataForm::MyPropertyDescriptor_Changed );
myTableStyle->GridColumnStyles->Add( myColumnStyle );
// Add the DataGridTableStyle instance to the GridTableStylesCollection.
myDataGrid->TableStyles->Add( myTableStyle );
TablesAlreadyAdded = true;
}
void MyPropertyDescriptor_Changed( Object^ /*sender*/, EventArgs^ /*e*/ )
{
myLabel->Text = "Property Descriptor Property of DataGridColumnStyle has changed";
}
private void myButton_Click(object sender, EventArgs e)
{
if(TablesAlreadyAdded)
{
return;
}
AddCustomDataTableStyle();
}
private void AddCustomDataTableStyle()
{
DataGridTableStyle myTableStyle = new DataGridTableStyle();
// Map DataGridTableStyle to a DataTable.
myTableStyle.MappingName = "Orders";
// Get CurrencyManager object.
CurrencyManager myCurrencyManager = (CurrencyManager)BindingContext[myDataSet,"Orders"];
// Use the CurrencyManager to get the PropertyDescriptor for column.
PropertyDescriptor myPropertyDescriptor = myCurrencyManager.GetItemProperties()["Amount"];
// Construct a 'DataGridColumnStyle' object changing its format to 'Currency'.
DataGridColumnStyle myColumnStyle = new DataGridTextBoxColumn(myPropertyDescriptor,"c",true);
// Add EventHandler function for PropertyDescriptorChanged Event.
myColumnStyle.PropertyDescriptorChanged+=new System.EventHandler(MyPropertyDescriptor_Changed);
myTableStyle.GridColumnStyles.Add(myColumnStyle);
// Add the DataGridTableStyle instance to the GridTableStylesCollection.
myDataGrid.TableStyles.Add(myTableStyle);
TablesAlreadyAdded=true;
}
private void MyPropertyDescriptor_Changed(object sender,EventArgs e)
{
myLabel.Text="Property Descriptor Property of DataGridColumnStyle has changed";
}
Private Sub myButton_Click(ByVal sender As Object, ByVal e As EventArgs)
If TablesAlreadyAdded Then
Return
End If
AddCustomDataTableStyle()
End Sub
Private Sub AddCustomDataTableStyle()
Dim myTableStyle As New DataGridTableStyle()
' Map DataGridTableStyle to a DataTable.
myTableStyle.MappingName = "Orders"
' Get CurrencyManager object.
Dim myCurrencyManager As CurrencyManager = CType(BindingContext(myDataSet, "Orders"), CurrencyManager)
' Use the CurrencyManager to get the PropertyDescriptor for column.
Dim myPropertyDescriptor As PropertyDescriptor = myCurrencyManager.GetItemProperties()("Amount")
' Construct a 'DataGridColumnStyle' object changing its format to 'Currency'.
Dim myColumnStyle As DataGridTextBoxColumn = New DataGridTextBoxColumn(myPropertyDescriptor, "c", True)
' Add EventHandler function for PropertyDescriptorChanged Event.
AddHandler myColumnStyle.PropertyDescriptorChanged, AddressOf MyPropertyDescriptor_Changed
myTableStyle.GridColumnStyles.Add(myColumnStyle)
' Add the DataGridTableStyle instance to the GridTableStylesCollection.
myDataGrid.TableStyles.Add(myTableStyle)
TablesAlreadyAdded = True
End Sub
Private Sub MyPropertyDescriptor_Changed(ByVal sender As Object, ByVal e As EventArgs)
myLabel.Text = "Property Descriptor Property of DataGridColumnStyle has changed"
End Sub
Si applica a
Collabora con noi su GitHub
L'origine di questo contenuto è disponibile in GitHub, in cui è anche possibile creare ed esaminare i problemi e le richieste pull. Per ulteriori informazioni, vedere la guida per i collaboratori.
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per