Export (0) Print
Expand All

DataGridColumnStyle.PropertyDescriptorChanged Event

Occurs when the PropertyDescriptor property value changes.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public event EventHandler PropertyDescriptorChanged
/** @event */
public void add_PropertyDescriptorChanged (EventHandler value)

/** @event */
public void remove_PropertyDescriptorChanged (EventHandler value)

JScript supports the use of events, but not the declaration of new ones.

For more information about handling events, see Consuming Events.

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";
}

protected void myButton_Click(Object sender, EventArgs e)
{
    if (TablesAlreadyAdded) {
        return;
    }
    AddCustomDataTableStyle();
} //myButton_Click

private void AddCustomDataTableStyle()
{
    DataGridTableStyle myTableStyle = new DataGridTableStyle();

    // Map DataGridTableStyle to a DataTable.
    myTableStyle.set_MappingName("Orders");

    // Get CurrencyManager object.
    CurrencyManager myCurrencyManager = (CurrencyManager)
        get_BindingContext().get_Item(myDataSet, "Orders");

    // Use the CurrencyManager to get the PropertyDescriptor for column.
    PropertyDescriptor myPropertyDescriptor = 
        myCurrencyManager.GetItemProperties().get_Item("Amount");

    // Construct a 'DataGridColumnStyle' object changing its format to 
    // 'Currency'.
    DataGridColumnStyle myColumnStyle = 
        new DataGridTextBoxColumn(myPropertyDescriptor, "c", true);

    // Add EventHandler function for PropertyDescriptorChanged Event.
    myColumnStyle.add_PropertyDescriptorChanged(new System.EventHandler(
        MyPropertyDescriptorChanged));
    myTableStyle.get_GridColumnStyles().Add(myColumnStyle);

    // Add the DataGridTableStyle instance to the GridTableStylesCollection. 
    myDataGrid.get_TableStyles().Add(myTableStyle);
    TablesAlreadyAdded = true;
} //AddCustomDataTableStyle

void MyPropertyDescriptorChanged(Object sender, EventArgs e)
{
    myLabel.set_Text("Property Descriptor Property of " 
        + "DataGridColumnStyle has changed");
} //MyPropertyDescriptorChanged

protected void myButton_Click(Object sender, EventArgs e)
{
    if(TablesAlreadyAdded) {
        return;
    }
    AddCustomDataTableStyle();
} //myButton_Click

private void AddCustomDataTableStyle()
{
    DataGridTableStyle myTableStyle = new DataGridTableStyle();

    // Map DataGridTableStyle to a DataTable.
    myTableStyle.set_MappingName("Orders");

    // Get CurrencyManager object.
    CurrencyManager myCurrencyManager = (CurrencyManager)
        get_BindingContext().get_Item(myDataSet, "Orders");

    // Use the CurrencyManager to get the PropertyDescriptor for column.
    PropertyDescriptor myPropertyDescriptor = myCurrencyManager.
        GetItemProperties().get_Item("Amount");

    // Construct a 'DataGridColumnStyle' object changing its format to 
    // 'Currency'.
    DataGridColumnStyle myColumnStyle = 
        new DataGridTextBoxColumn(myPropertyDescriptor, "c", true);

    // Add EventHandler function for PropertyDescriptorChanged Event.
    myColumnStyle.add_PropertyDescriptorChanged(new System.
        EventHandler(MyPropertyDescriptorChanged));
    myTableStyle.get_GridColumnStyles().Add(myColumnStyle);

    // Add the DataGridTableStyle instance to the 
    // GridTableStylesCollection. 
    myDataGrid.get_TableStyles().Add(myTableStyle);
    TablesAlreadyAdded = true;
} //AddCustomDataTableStyle

void MyPropertyDescriptorChanged(Object sender, EventArgs e)
{
    myLabel.set_Text("Property Descriptor Property of " 
        + "DataGridColumnStyle has changed");
} //MyPropertyDescriptorChanged

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft