다음을 통해 공유


DataGridTableStyle.ReadOnlyChanged 이벤트

정의

ReadOnly 값이 변경될 때 발생합니다.

public:
 event EventHandler ^ ReadOnlyChanged;
public event EventHandler ReadOnlyChanged;
member this.ReadOnlyChanged : EventHandler 
Public Custom Event ReadOnlyChanged As EventHandler 

이벤트 유형

EventHandler

예제

다음 코드 예제에서는이 멤버를 사용 하는 방법을 보여 줍니다.

protected:
   void AddTableStyle()
   {
      
      // Create a new DataGridTableStyle.
      myDataGridTableStyle = gcnew DataGridTableStyle;
      myDataGridTableStyle->MappingName = myDataSet1->Tables[ 0 ]->TableName;
      myDataGrid1->DataSource = myDataSet1->Tables[ 0 ];
      myDataGridTableStyle->ReadOnlyChanged += gcnew EventHandler( this, &Form1::MyReadOnlyChangedEventHandler );
      myDataGrid1->TableStyles->Add( myDataGridTableStyle );
   }

private:
   // Handle the 'ReadOnlyChanged' event.
   void MyReadOnlyChangedEventHandler( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      MessageBox::Show( "ReadOnly property is changed" );
   }

   // Handle the check box's CheckedChanged event
   void myCheckBox1_CheckedChanged( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      if ( myDataGridTableStyle->ReadOnly )
      {
         myDataGridTableStyle->ReadOnly = false;
      }
      else
      {
         myDataGridTableStyle->ReadOnly = true;
      }
   }
protected void AddTableStyle()
{
   // Create a new DataGridTableStyle.
   myDataGridTableStyle = new DataGridTableStyle();
   myDataGridTableStyle.MappingName = myDataSet1.Tables[0].TableName;
   myDataGrid1.DataSource=myDataSet1.Tables[0];
   myDataGridTableStyle.ReadOnlyChanged+=new EventHandler(MyReadOnlyChangedEventHandler);
   myDataGrid1.TableStyles.Add(myDataGridTableStyle);
}

// Handle the 'ReadOnlyChanged' event.
private void MyReadOnlyChangedEventHandler(object sender, EventArgs e)
{
   MessageBox.Show("ReadOnly property is changed");
}

// Handle the check box's CheckedChanged event
private void myCheckBox1_CheckedChanged(object sender, EventArgs e)
{
   if(myDataGridTableStyle.ReadOnly)
   {
      myDataGridTableStyle.ReadOnly=false;
   }
   else
   {
      myDataGridTableStyle.ReadOnly=true;
   }
}
Protected Sub AddTableStyle()
   ' Create a new DataGridTableStyle.
   myDataGridTableStyle = New DataGridTableStyle()
   myDataGridTableStyle.MappingName = myDataSet1.Tables(0).TableName
   myDataGrid1.DataSource = myDataSet1.Tables(0)
   AddHandler myDataGridTableStyle.ReadOnlyChanged, AddressOf MyReadOnlyChangedEventHandler
   myDataGrid1.TableStyles.Add(myDataGridTableStyle)
End Sub

' Handle the 'ReadOnlyChanged' event.
Private Sub MyReadOnlyChangedEventHandler(sender As Object, e As EventArgs)
   MessageBox.Show("ReadOnly property is changed")
End Sub

' Handle the check box's CheckedChanged event
Private Sub myCheckBox1_CheckedChanged(sender As Object, e As EventArgs)
   If myDataGridTableStyle.ReadOnly Then
      myDataGridTableStyle.ReadOnly = False
   Else
      myDataGridTableStyle.ReadOnly = True
   End If
End Sub

설명

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.

적용 대상

추가 정보