Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
245
Key Already Exists - summary totals for two columns in one grid
posted

I am still evaluating the controls and am playing around with the UltraWinGrid.

I am populating the grid from a datatable that pulls data based on an UltraCombo. I change the customer in the combo and the amounts owing are supposed to show in the grid.  It works for the most part (I've just duplicated what I had in a DataGridView).

One reason for looking at this grid is to more easily format and put totals on the grid.  So I have added summaries for two columns.  All my layout is currently in the InitailizeLayout event.  However, when I change the combo, it fires again and flags an error on the .Summaries.Add line in the code below.

Can anyone give me an idea of what to change and why it is doing this?  I've been reading that InitialiseLayout is the proper place to do this kind of thing but is there a better place?

Error is "Key Already Exists.  Parameter Name: Key"

Also, the summaries have a label at the left that says "Grand Summaries".  Any way to get rid of that text and possibly replace it with my own on the same line as the totals instead of the line above?

TIA

Private Sub ugCustomerDetail_InitializeLayout(sender As Object, e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles ugCustomerDetail.InitializeLayout

  e.Layout.Bands(0).Columns(5).Format = "M/dd/yyyy"
  e.Layout.Bands(0).Columns(9).Format = strNumberFormat
  e.Layout.Bands(0).Columns(10).Format = strNumberFormat
  e.Layout.Bands(0).Columns(5).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right
  e.Layout.Bands(0).Columns(9).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right
  e.Layout.Bands(0).Columns(10).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right

  e.Layout.Bands(0).Columns(9).AllowRowSummaries = Infragistics.Win.UltraWinGrid.AllowRowSummaries.True
  e.Layout.Bands(0).Columns(10).AllowRowSummaries = Infragistics.Win.UltraWinGrid.AllowRowSummaries.True

  e.Layout.Bands(0).Summaries.Add("Total", Infragistics.Win.UltraWinGrid.SummaryType.Sum, e.Layout.Bands(0).Columns(9), Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn)     'error on this line

  e.Layout.Bands(0).Summaries.Add("Total2", Infragistics.Win.UltraWinGrid.SummaryType.Sum, e.Layout.Bands(0).Columns(10), Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn)

  e.Layout.Bands(0).Summaries(0).SummaryDisplayArea = Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.BottomFixed
  e.Layout.Bands(0).Summaries(0).DisplayFormat = "{0:#,###.00}"
  e.Layout.Bands(0).Summaries(0).Appearance.TextHAlign = Infragistics.Win.HAlign.Right
  e.Layout.Bands(0).Summaries(0).Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True

  e.Layout.Bands(0).Summaries(1).SummaryDisplayArea = Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.BottomFixed
  e.Layout.Bands(0).Summaries(1).DisplayFormat = "{0:#,###.00}"
  e.Layout.Bands(0).Summaries(1).Appearance.TextHAlign = Infragistics.Win.HAlign.Right
  e.Layout.Bands(0).Summaries(1).Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True

 

  For x As Integer = 0 To 2
    e.Layout.Bands(0).Columns(x).Hidden = True
  Next

  e.Layout.Bands(0).Columns(4).Hidden = True

  For x As Integer = 6 To 7
    e.Layout.Bands(0).Columns(x).Hidden = True
  Next

End Sub