private void gridViewHalfHour_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) { /*if (e.ControllerRow != gridViewHalfHour.FocusedRowHandle && e.Action== CollectionChangeAction.Add ) * { * gridViewHalfHour.UnselectRow(e.ControllerRow); * }*/ }
/// <summary> /// 自定义列表单元格汇总方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <param name="toolTip1"></param> public static void CusGridView_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e, ToolTip toolTip1) { if (sender is GridView) { GridView gridView1 = sender as GridView; if (gridView1.GetSelectedCells().Count() > 0 && (gridView1.OptionsBehavior.ReadOnly || gridView1.OptionsBehavior.Editable == false)) { DevExpress.XtraGrid.Views.Base.GridCell[] gcs = gridView1.GetSelectedCells(); string strColumnName = ""; Decimal dTotal = 0; bool bIsCompute = false; for (int i = 0; i < gcs.Count(); i++) { DevExpress.XtraGrid.Views.Base.GridCell gc = gcs[i]; if (i == 0) { strColumnName = gc.Column.Name; } if (strColumnName != gc.Column.Name) { return; } if (gc.Column.SummaryItem.SummaryType == SummaryItemType.Sum) { if (gridView1.GetRowCellValue(gc.RowHandle, gc.Column) != null && gridView1.GetRowCellValue(gc.RowHandle, gc.Column).ToString() != "") { dTotal += Convert.ToDecimal(gridView1.GetRowCellValue(gc.RowHandle, gc.Column).ToString()); bIsCompute = true; } } } if (bIsCompute) { toolTip1.SetToolTip(gridView1.GridControl, ("合计:" + dTotal.ToString("f2"))); } //Console.WriteLine("选中单元格:" + gridView1.GetSelectedCells().Count().ToString()); } } }
private void gridView1_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) { }