DataGridColumnStyle.ReadOnlyChanged Evento
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Se produce cuando cambia el valor de la propiedad ReadOnly.
public:
event EventHandler ^ ReadOnlyChanged;
public event EventHandler ReadOnlyChanged;
member this.ReadOnlyChanged : EventHandler
Public Custom Event ReadOnlyChanged As EventHandler
Tipo de evento
Ejemplos
En el ejemplo de código siguiente se muestra el uso de este miembro.
private:
void Button_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
if ( myButton->Text->Equals( "Make column read/write" ) )
{
myDataGridColumnStyle->ReadOnly = false;
myButton->Text = "Make column read only";
}
else
{
myDataGridColumnStyle->ReadOnly = true;
myButton->Text = "Make column read/write";
}
}
void AddCustomDataTableStyle()
{
myDataGridTableStyle = gcnew DataGridTableStyle;
myDataGridTableStyle->MappingName = "Customers";
myDataGridColumnStyle = gcnew DataGridTextBoxColumn;
myDataGridColumnStyle->MappingName = "CustName";
// Add EventHandler function for readonlychanged event.
myDataGridColumnStyle->ReadOnlyChanged += gcnew EventHandler( this, &MyForm1::myDataGridColumnStyle_ReadOnlyChanged );
myDataGridColumnStyle->HeaderText = "Customer";
myDataGridTableStyle->GridColumnStyles->Add( myDataGridColumnStyle );
// Add the 'DataGridTableStyle' instance to the 'DataGrid'.
myDataGrid->TableStyles->Add( myDataGridTableStyle );
}
void myDataGridColumnStyle_ReadOnlyChanged( Object^ /*sender*/, EventArgs^ /*e*/ )
{
MessageBox::Show( "'Readonly' property is changed" );
}
private void Button_Click(Object sender, EventArgs e)
{
if (myButton.Text == "Make column read/write")
{
myDataGridColumnStyle.ReadOnly = false;
myButton.Text = "Make column read only";
}
else
{
myDataGridColumnStyle.ReadOnly = true;
myButton.Text = "Make column read/write";
}
}
private void AddCustomDataTableStyle()
{
myDataGridTableStyle = new DataGridTableStyle();
myDataGridTableStyle.MappingName = "Customers";
myDataGridColumnStyle = new DataGridTextBoxColumn();
myDataGridColumnStyle.MappingName= "CustName";
// Add EventHandler function for readonlychanged event.
myDataGridColumnStyle.ReadOnlyChanged += new EventHandler(myDataGridColumnStyle_ReadOnlyChanged);
myDataGridColumnStyle.HeaderText = "Customer";
myDataGridTableStyle.GridColumnStyles.Add(myDataGridColumnStyle);
// Add the 'DataGridTableStyle' instance to the 'DataGrid'.
myDataGrid.TableStyles.Add(myDataGridTableStyle);
}
private void myDataGridColumnStyle_ReadOnlyChanged(Object sender, EventArgs e)
{
MessageBox.Show("'Readonly' property is changed");
}
Private Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)
If myButton.Text = "Make column read/write" Then
myDataGridColumnStyle.ReadOnly = False
myButton.Text = "Make column read only"
Else
myDataGridColumnStyle.ReadOnly = True
myButton.Text = "Make column read/write"
End If
End Sub
Private Sub AddCustomDataTableStyle()
myDataGridTableStyle = New DataGridTableStyle()
myDataGridTableStyle.MappingName = "Customers"
myDataGridColumnStyle = New DataGridTextBoxColumn()
myDataGridColumnStyle.MappingName = "CustName"
' Add EventHandler function for readonlychanged event.
AddHandler myDataGridColumnStyle.ReadOnlyChanged, AddressOf myDataGridColumnStyle_ReadOnlyChanged
myDataGridColumnStyle.HeaderText = "Customer"
myDataGridTableStyle.GridColumnStyles.Add(myDataGridColumnStyle)
' Add the 'DataGridTableStyle' instance to the 'DataGrid'.
myDataGrid.TableStyles.Add(myDataGridTableStyle)
End Sub
Private Sub myDataGridColumnStyle_ReadOnlyChanged(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show("'Readonly' property is changed")
End Sub
Se aplica a
Col·laboreu amb nosaltres a GitHub
La font d'aquest contingut es pot trobar al GitHub, on també podeu crear i revisar problemes i sol·licituds d'extracció. Per obtenir més informació, consulteu la nostra guia per a col·laboradors.