DataGridColumnStyle.AlignmentChanged 事件
在 Alignment 属性值更改时发生。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Event AlignmentChanged As EventHandler
用法
Dim instance As DataGridColumnStyle
Dim handler As EventHandler
AddHandler instance.AlignmentChanged, handler
public event EventHandler AlignmentChanged
public:
event EventHandler^ AlignmentChanged {
void add (EventHandler^ value);
void remove (EventHandler^ value);
}
/** @event */
public void add_AlignmentChanged (EventHandler value)
/** @event */
public void remove_AlignmentChanged (EventHandler value)
JScript 支持使用事件,但不支持进行新的声明。
备注
有关处理事件的更多信息,请参见 使用事件。
示例
Private Sub AlignmentChanged_Click(ByVal sender As Object, ByVal e As EventArgs)
myMessage = "Alignment has been Changed"
End Sub 'AlignmentChanged_Click
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 'AddCustomDataTableStyle
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:
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 );
}
protected void AlignmentChanged_Click(Object sender, EventArgs e)
{
myMessage = "Alignment has been Changed";
} //AlignmentChanged_Click
private void AddCustomDataTableStyle()
{
// Create a 'DataGridTableStyle'.
DataGridTableStyle myDataTableStyle = new DataGridTableStyle();
myDataTableStyle.set_MappingName("Customers");
// Create a 'DataGridColumnStyle'.
myDataGridColumnStyle = new DataGridTextBoxColumn();
myDataGridColumnStyle.set_MappingName("CustName");
myDataGridColumnStyle.set_HeaderText("Customer Name");
myDataGridColumnStyle.set_Width(250);
myDataGridColumnStyle.add_AlignmentChanged(new EventHandler(
AlignmentChanged_Click));
// Add the 'DataGridColumnStyle' to 'DataGridTableStyle'.
myDataTableStyle.get_GridColumnStyles().Add(myDataGridColumnStyle);
// Add the 'DataGridTableStyle' to 'DataGrid'.
myDataGrid.get_TableStyles().Add(myDataTableStyle);
} //AddCustomDataTableStyle
平台
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 命名空间