Hi,
Please let me know how do I get the last row value in the summary. for example I have a column
----------------------------
Balance
1000
2300
3100
540
-----------------------------
Closing Bal: 540
Please let me know how do I achieve this.
Thank you,
Irfan
Hi Irfan,
You can get the value from any row you want in the grid. The questions are...
What row do you want?
What criteria are you using to determine that row?
and what assumptions can you make about the state of the grid? For example, are you allowing the user to change the GroupBy columns? Or are they fixed?
If the GroupBy columns are fixed, then the code I posted above will give you what you want. If this code is not what you want or it does not work, then you need to explain exactly what row you are trying to get.
The grid does not have a property that returns the last row regardless of the hierarchy.
Also... you keep mentioning the summary. The summary has nothing to do with the last row - other than that it happens to be a row which is part of that summaries calculations. What does the summary have to do with this?Are you just trying to get the value of the summary?
Hi Mike,
Thanks for the reply. As you said, this code is getting the data in the last row in the grid, but I need to get the data in the last row of each group. Is there any work around to get the reference of the last row in order to get the cell data in the summary.
The code you have here does not work because the rows collection in the grid is a collection of GroupByRows and GroupByRows do not have cells. Your rows are in a hierarchy.
What you want to do here is a bit weird. Trying to get a specific cell value in a specific row like this using only the criteria that it is the last row is a very unusual thing to do. You are making all sorts of assumptions about your data.
To get the cell you circled here, you have to get a reference to the row. How you get that depends on what your criteria are for which row you want. If you just want the last data row in the grid, then you would have to walk down the hierarchy until you get to the last row in the last level. Since Doing this in a way that will work regardless of the number of group by levels would be a bit tricky, since you would have to walk down the tree until you come to the level where there are data rows.
If you know that you will always have on a single level of GroupBy, then you could do this:
[code]
Dim groupByRow As UltraGridGroupByRow = CType(Me.UltraGrid1.Rows(Me.UltraGrid1.Rows.Count - 1), UltraGridGroupByRow) Debug.WriteLine(groupByRow.Rows(groupByRow.Rows.Count - 1).Cells("Balance").Value)
[/code
This is the scenario I have, what I need is the highlighted cell value in the Balance column as summary for 'Closing Bal'.
This is the code I use for this.
-----------------------------------------------------------------------------------------------------------------------------
Private Sub uwg_InitializeLayout_1(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles uwg.InitializeLayout
e.Layout.Bands(0).Summaries.Clear() e.Layout.Bands(0).Summaries.Add("Summary", Infragistics.Win.UltraWinGrid.SummaryType.Formula, Me.uwg.DisplayLayout.Bands(0).Columns("Balance"), Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn) e.Layout.Bands(0).Summaries("Summary").Formula = "" ' No formula Yet
e.Layout.Bands(0).Summaries("Summary").DisplayFormat = "Closing Bal= {0}"
End Sub
-------------------------------------------------------------------------------------------------------------------------------
Further when I tried to use find the value in the last row cell like this
uwg.Rows(uwg.Rows.Count - 1).Cells("Balance").Value
I am end up with Null Reference Exception.
Please let me know the possible work around,
If the grid is grouped, then the root-level rows in the grid will be GroupByRows. You would have to get the GroupByRow you want and the use it's Rows collection to get the real data rows.
But it's not clear to me which row you are trying to get here.
Are you trying to get the value of a cell? Or are you trying to get the value of a Summary? You seem to be using these interchangeably, but they are not the same thing.