int sum = 0;
for (int i = 0; i < this.gcMultiRow1.RowCount; i++) {
if ((this.gcMultiRow1.Rows.GetRowState(i) & MultiRowElementStates.Visible) == MultiRowElementStates.Visible)
{ sum += (int)this.gcMultiRow1.GetValue(i, 0); } } Console.WriteLine("合計: {0}", sum); var visibleRows = this.gcMultiRow1.Rows.Where(row => row.Visible);
Console.WriteLine("表示されている行数: {0}", visibleRows.Count());
var cellValues = visibleRows.Select(row => (int)row.Cells[0].Value);
var sum = cellValues.Sum();
Console.WriteLine("合計: {0}", sum);