[英]Which gridview of a list fires an event
I have a List
of GridView
and I want to add the same CellEndEdit
event at each GridView
. 我有一个GridView
List
,我想在每个GridView
上添加相同的CellEndEdit
事件。
it is possible to determine which gridview fire the CellEndEdit
event ? 有可能确定哪个gridview触发CellEndEdit
事件?
lst.Add(new RadGridView());
RadGridView radgridview= lst.Last();
radgridview.CellEndEdit += new GridViewCellEventHandler(radgridview_CellEndEdit);
private void radgridview_CellEndEdit(object sender, GridViewCellEventArgs e)
{
//I want to know here which radgridview is modified
}
The standard event pattern passes the source of the event as argument in the sender
parameter. 标准事件模式将事件源作为参数传递给sender
参数。 So you can simply cast sender
to RadGridView
and have the relevant instance: 所以你可以简单地将sender
RadGridView
为RadGridView
并拥有相关的实例:
private void radgridview_CellEndEdit(object sender, GridViewCellEventArgs e)
{
RadGridView sendingGridView = sender as RadGridView;
if (sendingGridView == null || !lst.Contains(sendingGridView))
return; // just to be sure
}
Obviously in this case the sender
is a GridViewEditManager
, so you may get your RadGridView
like this: 显然在这种情况下sender
是GridViewEditManager
,所以你可以得到你的RadGridView
:
private void radgridview_CellEndEdit(object sender, GridViewCellEventArgs e)
{
GridViewEditManager manager = sender as GridViewEditManager;
RadGridView sendingGridView = manager?.GridViewElement?.GridControl;
if (sendingGridView == null || !lst.Contains(sendingGridView))
return; // just to be sure
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.