?
Solved

Changing summary value for UltraWinGrid

Posted on 2009-03-31
5
Medium Priority
?
5,469 Views
Last Modified: 2013-11-15
I am using ultrawingrid which summary enabled showing the sum of the column. Now I want to make the summary value to zero and it should show only tthe sum of those rows which i select using check box.
0
Comment
Question by:srikanthreddyn143
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
ID: 24033447
The summary value in a column is a read-only property, so you can't just force it to be a value.  Instead, you can create a custom summary calculator.

The following example assumes you have a column "Selected" (boolean) and a column "ValueColumn" (decimal).  After you check/uncheck the Selected cell, it will automatically re-calculate the summary (if it's in view)
	Private Class MyCustomSummarySettings
		Implements ICustomSummaryCalculator
 
		Private decTotal As Decimal = 0.0
 
		Public Sub New()
		End Sub
 
		'Reset the summary total
		Private Sub BeginCustomSummary(ByVal summarySettings As SummarySettings, ByVal rows As RowsCollection) Implements ICustomSummaryCalculator.BeginCustomSummary
			decTotal = 0
		End Sub
 
		'Perform the summary 
		Private Sub AggregateCustomSummary(ByVal summarySettings As SummarySettings, ByVal row As UltraGridRow) Implements ICustomSummaryCalculator.AggregateCustomSummary
			If Not row.Cells("Selected").Value Then Exit Sub
 
			Try
				decTotal += Convert.ToDecimal(row.GetCellValue(summarySettings.SourceColumn))
			Catch ex As Exception
				MsgBox("Error converting cell value to decimal", MsgBoxStyle.Critical)
			End Try
		End Sub
 
		'Return the summary value
		Private Function EndCustomSummary(ByVal summarySettings As SummarySettings, ByVal rows As RowsCollection) Implements ICustomSummaryCalculator.EndCustomSummary
			Return decTotal
		End Function
	End Class
 
	Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout
		Dim summary As Infragistics.Win.UltraWinGrid.SummarySettings
 
		'Create a new summary object for the band
		summary = UltraGrid1.DisplayLayout.Bands(0).Summaries.Add("CustomSummary")
 
		summary.SummaryType = SummaryType.Custom
		summary.SourceColumn = UltraGrid1.DisplayLayout.Bands(0).Columns("ValueColumn")
		summary.CustomSummaryCalculator = New MyCustomSummarySettings
	End Sub

Open in new window

0
 
LVL 11

Author Comment

by:srikanthreddyn143
ID: 24034236
Hi Zeon,

Thanks for your reply.It was throwing an exception "Cannot convert 'True' to Long" when i used code in this way.

 'Perform the summary 
    Private Sub AggregateCustomSummary(ByVal summarySettings As SummarySettings, ByVal row As UltraGridRow) Implements ICustomSummaryCalculator.AggregateCustomSummary
        Try
            If Not row.Cells("CB").Value.ToString Then
                Exit Sub
            Else
                decTotal += Convert.ToDecimal(row.Cells("Amount").Value)
            End If
        Catch ex As Exception
            ExceptionManager.Publish(ex)
        End Try
    End Sub

Open in new window

0
 
LVL 11

Author Comment

by:srikanthreddyn143
ID: 24034252
It was throwing exception At line "If Not row.Cells("CB").Value"
0
 
LVL 11

Author Comment

by:srikanthreddyn143
ID: 24034831
Thanks.
Its working fine when i kept "If Not row.Cells("CB").Value = "True" Then ". But how can I have the summary as a footer. Right now it is scrolling with the datagrid.
0
 
LVL 11

Author Comment

by:srikanthreddyn143
ID: 24038702
Thank you. Thats fine.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question