ColumnClickEventArgs.Column 属性

定义

获取单击的列的从零开始的索引。

public:
 property int Column { int get(); };
public int Column { get; }
member this.Column : int
Public ReadOnly Property Column As Integer

属性值

单击的列内的 ListView.ColumnHeaderCollection 从零开始的索引。

示例

下面的代码示例演示了此成员的使用。 在此示例中,事件处理程序报告事件的发生情况 ListView.ColumnClick 。 此报告可帮助你了解事件发生的时间,并可以帮助你进行调试。 若要报告多个事件或频繁发生的事件,请考虑替换MessageBox.ShowConsole.WriteLine或将消息追加到多行TextBox

若要运行示例代码,请将其粘贴到包含命名ListView类型的ListView1实例的项目中。 然后,确保事件处理程序与 ListView.ColumnClick 事件相关联。

private void ListView1_ColumnClick(Object sender, ColumnClickEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Column", e.Column );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "ColumnClick Event" );
}
Private Sub ListView1_ColumnClick(sender as Object, e as ColumnClickEventArgs) _ 
     Handles ListView1.ColumnClick

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Column", e.Column)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"ColumnClick Event")

End Sub

注解

可以使用该事件的事件处理程序 ColumnClick 中此属性提供的信息来确定要单击哪个列以对列中的数据执行任务。

适用于

另请参阅