DataGridColumnStyle.NullTextChanged 事件

NullText 值更改时发生。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Event NullTextChanged As EventHandler
用法
Dim instance As DataGridColumnStyle
Dim handler As EventHandler

AddHandler instance.NullTextChanged, handler
public event EventHandler NullTextChanged
public:
event EventHandler^ NullTextChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
/** @event */
public void add_NullTextChanged (EventHandler value)

/** @event */
public void remove_NullTextChanged (EventHandler value)
JScript 支持使用事件,但不支持进行新的声明。

备注

有关处理事件的更多信息,请参见 使用事件

示例

Private Sub AddCustomColumnStyle()
   myTableStyle = New DataGridTableStyle()
   myColumnStyle = New DataGridTextBoxColumn()
   AddHandler myColumnStyle.NullTextChanged, AddressOf columnStyle_NullTextChanged
   myTableStyle.GridColumnStyles.Add(myColumnStyle)
   myDataGrid.TableStyles.Add(myTableStyle)
End Sub 'AddCustomColumnStyle

' NullTextChanged event handler of DataGridColumnStyle.
Private Sub columnStyle_NullTextChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim i As Integer
   For i = 0 To myRowcount - 1
      myCell.RowNumber = i
      myDataGrid(myCell) = Nothing
   Next i
   MessageBox.Show("NullTextChanged Event is handled")
End Sub 'columnStyle_NullTextChanged
private void AddCustomColumnStyle()
{
   myTableStyle = new DataGridTableStyle();
   myColumnStyle = new DataGridTextBoxColumn();
   myColumnStyle.NullTextChanged += new EventHandler(columnStyle_NullTextChanged);
   myTableStyle.GridColumnStyles.Add(myColumnStyle);
   myDataGrid.TableStyles.Add(myTableStyle);
 
}
// NullTextChanged event handler of DataGridColumnStyle.
private void columnStyle_NullTextChanged(object sender, EventArgs e)
{
   for(int i=0;i<myRowcount;i++)
   {
      myCell.RowNumber = i;
      myDataGrid[myCell] = null;
   }
   MessageBox.Show("NullTextChanged Event is handled");
}
private:
   void AddCustomColumnStyle()
   {
      myTableStyle = gcnew DataGridTableStyle;
      myColumnStyle = gcnew DataGridTextBoxColumn;
      myColumnStyle->NullTextChanged += gcnew EventHandler( this, &MyForm::columnStyle_NullTextChanged );
      myTableStyle->GridColumnStyles->Add( myColumnStyle );
      myDataGrid->TableStyles->Add( myTableStyle );
   }

   // NullTextChanged event handler of DataGridColumnStyle.
   void columnStyle_NullTextChanged( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      for ( int i = 0; i < myRowcount; i++ )
      {
         myCell.RowNumber = i;
         myDataGrid[ myCell ] = nullptr;

      }
      MessageBox::Show( "NullTextChanged Event is handled" );
   }
private void AddCustomColumnStyle()
{
    myTableStyle = new DataGridTableStyle();
    myColumnStyle = new DataGridTextBoxColumn();
    myColumnStyle.add_NullTextChanged(new EventHandler(
        columnStyle_NullTextChanged));
    myTableStyle.get_GridColumnStyles().Add(myColumnStyle);
    myDataGrid.get_TableStyles().Add(myTableStyle);
} //AddCustomColumnStyle

// NullTextChanged event handler of DataGridColumnStyle.
private void columnStyle_NullTextChanged(Object sender, EventArgs e)
{
    for(int i = 0; i < myRowcount; i++) {
        myCell.set_RowNumber(i);
        myDataGrid.set_Item(myCell, null);
    }
    MessageBox.Show("NullTextChanged Event is handled");
} //columnStyle_NullTextChanged

平台

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

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

DataGridColumnStyle 类
DataGridColumnStyle 成员
System.Windows.Forms 命名空间
EnterNullValue