如何使用 ObjectListView 库处理点击事件?

How do I handle a click event using the ObjectListView library?

我正在尝试使用 TreeListView,我看到了这个 post:How to create a MultiColumn treeview like this in C# Winforms app?。 但是我不明白当我点击树节点时如何处理事件。 你能帮帮我吗?

我试过将这样的事件添加到表单中:

private void treeListView_Click(object sender, EventArgs e){
    Debug.Print("HI");
}

但是没用。

感谢@Robert Harvey 的回答,我添加了

treeListView.CellClick += treeListView_CellClick; 进入 FillTree 方法,其中

private void treeListView_CellClick(object sender, BrightIdeasSoftware.CellClickEventArgs e)
        {
            Debug.Print("hi");
        }

即post使用了ObjectListView library。如果您下载该库的源代码,在 Visual Studio 中打开它并检查 Events.cs,您会在 TreeListView 的部分 class 中找到:

/// <summary>
/// This event is triggered when user input requests the expansion of a list item.
/// </summary>
[Category("ObjectListView"),
Description("This event is triggered when a branch is about to expand.")]
public event EventHandler<TreeBranchExpandingEventArgs> Expanding;

/// <summary>
/// This event is triggered when user input requests the collapse of a list item.
/// </summary>
[Category("ObjectListView"),
Description("This event is triggered when a branch is about to collapsed.")]
public event EventHandler<TreeBranchCollapsingEventArgs> Collapsing;

/// <summary>
/// This event is triggered after the expansion of a list item due to user input.
/// </summary>
[Category("ObjectListView"),
Description("This event is triggered when a branch has been expanded.")]
public event EventHandler<TreeBranchExpandedEventArgs> Expanded;

/// <summary>
/// This event is triggered after the collapse of a list item due to user input.
/// </summary>
[Category("ObjectListView"),
Description("This event is triggered when a branch has been collapsed.")]
public event EventHandler<TreeBranchCollapsedEventArgs> Collapsed;

该文件中还为 ObjectListView class 本身定义了一堆事件,包括这个:

/// <summary>
/// Triggered when a cell is left clicked.
/// </summary>
[Category("ObjectListView"),
Description("This event is triggered when the user left clicks a cell.")]
public event EventHandler<CellClickEventArgs> CellClick;