使用 GridWeb 双击事件

启用双击事件

通过将 GridWeb 控件的 EnableDoubleClickEvent 属性设置为 true,可以在客户端启用所有类型的双击事件。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Enabling Double Click events
GridWeb1.EnableDoubleClickEvent = true;

一旦启用了双击事件,就可以为任何双击事件创建事件处理程序。当给定的双击事件被触发时,这些事件处理程序执行特定的任务。

处理双击事件

要在 Visual Studio 中创建事件处理程序:

  1. 双击事件在“属性”窗格中列出。

对于此示例,我们为各种双击事件实现了事件处理程序。

双击 Cell

CellDoubleClick 事件的事件处理程序提供了一个 CellEventArgs 类型的参数,它提供了被双击的单元格的完整信息。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Event Handler for CellDoubleClick event
protected void GridWeb1_CellDoubleClick(object sender, Aspose.Cells.GridWeb.CellEventArgs e)
{
// Displaying the name of the cell (that is double clicked) in GridWeb's Message Box
string msg = "You just clicked <";
msg += "Row: " + (e.Cell.Row + 1) + " Column: " + (e.Cell.Column + 1) + " Cell Name: " + e.Cell.Name + ">";
GridWeb1.Message = msg;
}

双击列标题

ColumnDoubleClick 事件的事件处理程序提供 RowColumnEventArgs 类型的参数,该参数提供被双击的标题的列索引号和其他信息。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Event Handler for ColumnDoubleClick event
protected void GridWeb1_ColumnDoubleClick(object sender, Aspose.Cells.GridWeb.RowColumnEventArgs e)
{
// Displaying the number of the column (whose header is double clicked) in GridWeb's Message Box
string msg = "You just clicked <";
msg += "Column header: " + (e.Num + 1) + ">";
GridWeb1.Message = msg;
}

双击行标题

RowDoubleClick 事件的事件处理程序提供了一个 RowColumnEventArgs 类型的参数,该参数提供了被双击的标题行的索引号和其他相关信息。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Event Handler for RowDoubleClick event
protected void GridWeb1_RowDoubleClick(object sender, Aspose.Cells.GridWeb.RowColumnEventArgs e)
{
// Displaying the number of the row (whose header is double clicked) in GridWeb's Message Box
string msg = "You just clicked <";
msg += "Row header: " + (e.Num + 1) + ">";
GridWeb1.Message = msg;
}