DataGridColumnStyle.AlignmentChanged 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
發生在 Alignment 屬性值變更時。
public:
event EventHandler ^ AlignmentChanged;
public event EventHandler AlignmentChanged;
member this.AlignmentChanged : EventHandler
Public Custom Event AlignmentChanged As EventHandler
事件類型
範例
下列程式碼範例示範此成員的使用。
private:
void AlignmentChanged_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
myMessage = "Alignment has been Changed";
}
void AddCustomDataTableStyle()
{
// Create a 'DataGridTableStyle'.
DataGridTableStyle^ myDataTableStyle = gcnew DataGridTableStyle;
myDataTableStyle->MappingName = "Customers";
// Create a 'DataGridColumnStyle'.
myDataGridColumnStyle = gcnew DataGridTextBoxColumn;
myDataGridColumnStyle->MappingName = "CustName";
myDataGridColumnStyle->HeaderText = "Customer Name";
myDataGridColumnStyle->Width = 250;
myDataGridColumnStyle->AlignmentChanged += gcnew EventHandler( this, &Form1::AlignmentChanged_Click );
// Add the 'DataGridColumnStyle' to 'DataGridTableStyle'.
myDataTableStyle->GridColumnStyles->Add( myDataGridColumnStyle );
// Add the 'DataGridTableStyle' to 'DataGrid'.
myDataGrid->TableStyles->Add( myDataTableStyle );
}
private void AlignmentChanged_Click(object sender, EventArgs e)
{
myMessage = "Alignment has been Changed";
}
private void AddCustomDataTableStyle()
{
// Create a 'DataGridTableStyle'.
DataGridTableStyle myDataTableStyle = new DataGridTableStyle();
myDataTableStyle.MappingName = "Customers";
// Create a 'DataGridColumnStyle'.
myDataGridColumnStyle = new DataGridTextBoxColumn();
myDataGridColumnStyle.MappingName = "CustName";
myDataGridColumnStyle.HeaderText = "Customer Name";
myDataGridColumnStyle.Width = 250;
myDataGridColumnStyle.AlignmentChanged+=new EventHandler(AlignmentChanged_Click);
// Add the 'DataGridColumnStyle' to 'DataGridTableStyle'.
myDataTableStyle.GridColumnStyles.Add(myDataGridColumnStyle);
// Add the 'DataGridTableStyle' to 'DataGrid'.
myDataGrid.TableStyles.Add(myDataTableStyle);
}
Private Sub AlignmentChanged_Click(ByVal sender As Object, ByVal e As EventArgs)
myMessage = "Alignment has been Changed"
End Sub
Private Sub AddCustomDataTableStyle()
' Create a 'DataGridTableStyle'.
Dim myDataTableStyle As New DataGridTableStyle()
myDataTableStyle.MappingName = "Customers"
' Create a 'DataGridColumnStyle'.
myDataGridColumnStyle = New DataGridTextBoxColumn()
myDataGridColumnStyle.MappingName = "CustName"
myDataGridColumnStyle.HeaderText = "Customer Name"
myDataGridColumnStyle.Width = 250
AddHandler myDataGridColumnStyle.AlignmentChanged, AddressOf AlignmentChanged_Click
' Add the 'DataGridColumnStyle' to 'DataGridTableStyle'.
myDataTableStyle.GridColumnStyles.Add(myDataGridColumnStyle)
' Add the 'DataGridTableStyle' to 'DataGrid'.
myDataGrid.TableStyles.Add(myDataTableStyle)
End Sub