- 积分
- 328
- 在线时间
- 53 小时
- 主题
- 0
- 注册时间
- 2019-5-23
- 帖子
- 22
- 最后登录
- 2024-12-12
- 帖子
- 22
- 软币
- 777
- 在线时间
- 53 小时
- 注册时间
- 2019-5-23
|
发表于 2022-9-20 10:38:34
|
显示全部楼层
前段时间刚好实现了类似功能,代码如下
protected virtual void OrderGridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
GridView view = (GridView)sender;
ToolTipControllerShowEventArgs args = toolTipController1.CreateShowArgs();
args.ToolTip = GetSelectedRows(view);
args.Title = "";
toolTipController1.ShowHint(args);
}
protected virtual string GetSelectedRows(GridView view)
{
List<selectCellvalue> selectdata = new List<selectCellvalue>();
string ret = "";
int rowIndex = -1;
if (view.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CellSelect)
{
foreach (GridCell cell in view.GetSelectedCells())
{
decimal res;
if (decimal.TryParse(view.GetRowCellDisplayText(cell.RowHandle, cell.Column),out res))
{
selectdata.Add(new selectCellvalue()
{
key = 1,
value = Convert.ToDecimal(view.GetRowCellDisplayText(cell.RowHandle, cell.Column))
});
}
rowIndex = cell.RowHandle;
}
if (selectdata.Count > 0)
{
ret = $"总和:" + selectdata.Sum(x => x.value);
ret += $"{Environment.NewLine}最小值:" + selectdata.Min(x => x.value);
ret += $"{Environment.NewLine}最大值:" + selectdata.Max(x => x.value);
ret += $"{Environment.NewLine}平均值:" + Math.Round( selectdata.Average(x => x.value),2);
ret += $"{Environment.NewLine}个数:" + selectdata.Count;
}
}
return ret;
} |
|