处理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. 在属性窗格的事件列表中双击一个事件。

在本示例中,我们为各种双击事件实现了事件处理程序。

双击单元格

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;
}