Home Forums WinForms controls Xceed Grid for WinForms Summary Row/Cells

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15924 |

    I have a databound grid control which I need to simply add a summary row with a SUM cell for each column, except the first, which should be the text “Total:”. I can’t figure out how to go about doing this and have searched the forums and the docs. Will someone provide some logic or code for me? I’m using VB.NET.

    Thanks!
    Drew

    Imported from legacy forums. Posted by Drew (had 2572 views)

    Xceed Support
    Member
    Post count: 5658

    You need to assign the “Total” string, to the second cell and consider the first cell as empty.

    Here is a snippet that shows how to implement that.

    <code>
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    For j As Integer = 0 To 3
    Dim col As New Column(“Column” + j.ToString(), GetType(Integer))
    gridControl1.Columns.Add(col)
    Next
    For i As Integer = 0 To 19

    Dim row As Xceed.Grid.DataRow = gridControl1.DataRows.AddNew()
    For Each cell As Cell In row.Cells
    cell.Value = i * 10
    Next
    row.EndEdit()
    Next

    Dim sumRow As New SummaryRow()
    gridControl1.FixedFooterRows.Add(sumRow)

    DirectCast(sumRow.Cells(“Column1”), SummaryCell).TitleFormat = “Total”
    DirectCast(sumRow.Cells(“Column1”), SummaryCell).TitlePosition = TitlePosition.AlwaysLeft
    DirectCast(sumRow.Cells(“Column1”), SummaryCell).StatFunction = StatFunction.Sum
    DirectCast(sumRow.Cells(“Column2”), SummaryCell).StatFunction = StatFunction.Sum
    DirectCast(sumRow.Cells(“Column3”), SummaryCell).StatFunction = StatFunction.Sum
    End Sub
    </code>

    Imported from legacy forums. Posted by CharlesB (had 392 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you! This works great!

    Imported from legacy forums. Posted by Drew (had 3462 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.