We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Summary row

Thread ID:

Created:

Updated:

Platform:

Replies:

14262 May 23,2004 06:48 PM UTC May 26,2004 08:39 PM UTC Windows Forms 10
loading
Tags: GridControl
Patrick Noble
Asked On May 23, 2004 06:48 PM UTC

I want to create a summary row, in a GridDataBoundGrid that does a sum of the values above it for each column. From previous postings it looks like I need to create a row of formula cells at the end of the databound rows, set the CellType to "Formula" and set the CellValue to the required formula. I have tried using the grid.Model.ChangeCells method to achieve this but the only value I appear to be able to alter is CellValue. For example, the code below only changes the contents of the specified range of cells to 9 and does not alter the BackColor or the font. Have I missed something? Dim style As GridStyleInfo style = New GridStyleInfo ''set some properties style.BackColor = Color.Aquamarine style.CellValue = 9 style.Font.Italic = True grid.Model.ChangeCells(GridRangeInfo.Cells(3, 3, 4, 4), style)

Administrator [Syncfusion]
Replied On May 23, 2004 08:43 PM UTC

You cannot set particular cell style properties in a GridDataBoundGrid since this grid holds no cell specific style properties. Here is a KB article that discusses how you set style properties on individual cells using PrepareViewStyleInfo. http://www.syncfusion.com/Support/article.aspx?id=560 But trying to use formulacells in a GridDataBoundGrid is more problematic. Here is a forum thread discussing this issue. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=2956 (There is also a KB with thsame information). Another way you can have a summary row is to use the technique discussed in this KB. It has a class you can use to do this. http://www.syncfusion.com/Support/article.aspx?id=10398

Patrick Noble
Replied On May 24, 2004 08:58 AM UTC

Got the GridSummaryRow class to work with a bit of massaging (it assumes only one header row for example) and now have another problem that manifests as a result. The CalculateValues method iterates through each column in the grid to calculate initial totals for the summary row. It uses grid.Model.ColCount for this purpose but this value for my second grid in my splitter control is 32 when I only have 26 columns, so it errors on column 27. My second grid is based on columns cloned from my first grid, and the first grid works fine with grid.Model.ColCount being 26. The code used for cloning is below and from the debug lines I can see that the ColCount for gridWeek2 is 1 before the clone statement and 32 immediately after it. What could be causing this? For Each gbc In gridWeek1.GridBoundColumns Debug.WriteLine("ColCount = " & gridWeek2.Model.ColCount.ToString) gridWeek2.GridBoundColumns.Add(gbc.Clone) Debug.WriteLine("ColCount = " & gridWeek2.Model.ColCount.ToString) gridWeek3.GridBoundColumns.Add(gbc.Clone) gridWeek4.GridBoundColumns.Add(gbc.Clone) gridWeek5.GridBoundColumns.Add(gbc.Clone) Next >You cannot set particular cell style properties in a GridDataBoundGrid since this grid holds no cell specific style properties. Here is a KB article that discusses how you set style properties on individual cells using PrepareViewStyleInfo. > >http://www.syncfusion.com/Support/article.aspx?id=560 > >But trying to use formulacells in a GridDataBoundGrid is more problematic. Here is a forum thread discussing this issue. >http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=2956 (There is also a KB with thsame information). > >Another way you can have a summary row is to use the technique discussed in this KB. It has a class you can use to do this. >http://www.syncfusion.com/Support/article.aspx?id=10398

Patrick Noble
Replied On May 24, 2004 09:04 AM UTC

BTW, 32 is the number of columns in the source datatable. >Got the GridSummaryRow class to work with a bit of massaging (it assumes only one header row for example) and now have another problem that manifests as a result. The CalculateValues method iterates through each column in the grid to calculate initial totals for the summary row. It uses grid.Model.ColCount for this purpose but this value for my second grid in my splitter control is 32 when I only have 26 columns, so it errors on column 27. My second grid is based on columns cloned from my first grid, and the first grid works fine with grid.Model.ColCount being 26. The code used for cloning is below and from the debug lines I can see that the ColCount for gridWeek2 is 1 before the clone statement and 32 immediately after it. What could be causing this? > > For Each gbc In gridWeek1.GridBoundColumns > Debug.WriteLine("ColCount = " & gridWeek2.Model.ColCount.ToString) > gridWeek2.GridBoundColumns.Add(gbc.Clone) > Debug.WriteLine("ColCount = " & gridWeek2.Model.ColCount.ToString) > gridWeek3.GridBoundColumns.Add(gbc.Clone) > gridWeek4.GridBoundColumns.Add(gbc.Clone) > gridWeek5.GridBoundColumns.Add(gbc.Clone) > Next > > >>You cannot set particular cell style properties in a GridDataBoundGrid since this grid holds no cell specific style properties. Here is a KB article that discusses how you set style properties on individual cells using PrepareViewStyleInfo. >> >>http://www.syncfusion.com/Support/article.aspx?id=560 >> >>But trying to use formulacells in a GridDataBoundGrid is more problematic. Here is a forum thread discussing this issue. >>http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=2956 (There is also a KB with thsame information). >> >>Another way you can have a summary row is to use the technique discussed in this KB. It has a class you can use to do this. >>http://www.syncfusion.com/Support/article.aspx?id=10398

Administrator [Syncfusion]
Replied On May 24, 2004 10:47 AM UTC

A few things to try. One is to call grid.Model.ResetVolatileData() after you have added the gridboundcolumns. Another thing to try is calling grid.Binder.InitializeColumns() after you have added the columns. Also, before you add the gridboundcolumns, try calling grid.GridBoundColumns.Clear().

Patrick Noble
Replied On May 24, 2004 01:08 PM UTC

I was already using grid.Binder.InitializeColumns() but ResetVolatileData fixed the problem, thanks.

Patrick Noble
Replied On May 26, 2004 05:05 PM UTC

Clay I now have a problem with the GridSummaryRow class owing to the fact that when the user changes a value in one cell in the databound grid, I update the value in an analysis column in the datatable on the same row. The summary row is updated OK for the column of data entry but not for the analysis column, presumably because the SaveCellInfo event is not fired for changes in the grid as a result of changes in underlying data. I handle the ColumnChange event on the underlying datatable in order to update the analysis column and I think the easiest solution may be to overload the GridSummaryRow.CalculateValues method to include a grid and column within the grid. I can then call that from the ColumnChange handler, but I need to determine the index of the grid column that is bound to the analysis column in the datatable. How do I get this? Or do you have a more elegant solution?

Administrator [Syncfusion]
Replied On May 26, 2004 05:17 PM UTC

You can get the grid''s ColIndex from teh datatable column name using int colIndex = grid.Binder.NameToColIndex("ColumnName"); You say you change a second value directly in the DataTable when the user changes a first value in the grid. Can you try changing this second value directly in the grid? (grid[row, col].CellValue = xxxxx) This would fire SaveCellInfo and maybe everything else would just work.

Patrick Noble
Replied On May 26, 2004 07:18 PM UTC

Instead of NameToColIndex I have tried to use FieldToColIndex since the ordinal of the column that changed is directly available to me from the handler event args. Unfortunately it is not doing what I expected since the number it returns is certainly not the index of the grid column that is bound to the datacolumn that changed, it is out by 6. Have I misunderstood this method?

Patrick Noble
Replied On May 26, 2004 07:50 PM UTC

Clay I have this working with NameToColIndex so I''m OK now, but still curious why the FieldToColIndex gives the wrong result.

Administrator [Syncfusion]
Replied On May 26, 2004 08:39 PM UTC

The field refers to the index of the column in either the grid.GridBoundColumns collection or in the grid.Binder.InternalColumns collection if you have not explicitly added gridboundcolumns. The field is not neccesary the index of the column in the DataTable.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;