We've recently upgraded to the verion 10.2.20102.1004. I have a grid in which a single group is created in the gird. When this grid initially loads and is populated it displays as expected, but when the underlying data set is reset and the Group is cleared the columns are not retainging thier widths. Please note that the gird is created dynamicly at runtime. Thre were no such issues in version 3.1.20041.1044, but we're getting the anomaly since upgrading. Any ideas? Here's a sample of the code that worked in the older version, perhaps I need to do something else to retain the column widths. Unable to find anything on your site regading this sort of behavior, please advice.
Private Sub PopDetailGrid() With grdDetail .SuspendLayout() .DisplayLayout.Bands(0).Groups.Clear() NewgrdDetail.PopGridData(rsGLTransdata)
If (_columWidths.Count = 0) Then SetDetailColumnWidths() End If
With .DisplayLayout.Bands(0)
' Add a group with the key of G1 .Groups.Add("G1") .LevelCount = 2 .GroupHeadersVisible = False .Groups("G1").Columns.Add(.Columns("GLAccount")) .Groups("G1").Columns.Add(.Columns("GLPeriod")) .Groups("G1").Columns.Add(.Columns("ActivityPeriod")) .Groups("G1").Columns.Add(.Columns("Batch")) .Groups("G1").Columns.Add(.Columns("TransType")) .Groups("G1").Columns.Add(.Columns("TransDate")) .Groups("G1").Columns.Add(.Columns("TransRef")) .Groups("G1").Columns.Add(.Columns("Agreement")) .Groups("G1").Columns.Add(.Columns("Company")) .Groups("G1").Columns.Add(.Columns("TransAmount")) .Groups("G1").Columns.Add(.Columns("TransDescr")) .Columns("TransDescr").Level = 1 .Override.CellAppearance.BackColor = Color.White .Override.RowFilterMode = RowFilterMode.AllRowsInBand .Columns("TransDescr").Header.Caption = "" Dim cCol As UltraGridColumn = .Columns("TransAmount") .Summaries.Clear() Dim sSum As SummarySettings sSum = .Summaries.Add("avgTransAmount", SummaryType.Average, cCol, SummaryPosition.Left) With sSum .Appearance.BackColor = Color.LightBlue .DisplayFormat = "{0:Transaction Average: $#,###.00}" .SummaryPosition = SummaryPosition.Right .Appearance.TextHAlign = HAlign.Right .Hidden = True End With sSum = .Summaries.Add("sumTransAmount", SummaryType.Sum, cCol, SummaryPosition.Right) With sSum .Appearance.BackColor = Color.LightBlue .DisplayFormat = "{0:Transaction Total: $#,###.00}" .SummaryPosition = SummaryPosition.Right .Appearance.TextHAlign = HAlign.Right .Hidden = True End With End With UpdateTotalLabel() SetGrid(grdDetail) SetGridLines(grdDetail) .DisplayLayout.Scrollbars = UltraWinGrid.Scrollbars.Vertical .ActiveRow = Nothing .FlatMode = True .BringToFront() .ResumeLayout() End With lblRecordCount.Text = Format(Me.grdDetail.Rows.VisibleRowCount, "#,##0") _ & " records visible of " & Format(Me.grdDetail.Rows.Count, "#,##0") _ & " records retrieved out of " & Format(rsGLTransdata.Count, "#,##0") _ & " records for the selected GL Periods." End Sub
Sorry for the confusion hopefully I can explain better below.
Here are the exact steps:
1. The grid is added to the main form, using metadata (column widths, grid width\height..etc..) stored in tables
2. After the grid is added, its data source is then populated, displaying data in which it is configured to display.
3. User selects criteria on the parent form
4. Code then creates a new dataset which is then passed to the grids data source property to be displayed. This is when the grid loses its formatting, the column widths to be exact.
What I mean by repopulating the grid simply means when the user selects criteria on the parent form which would cause the grid to filter or repopulate its data source, which would be a condensed dataset but the fields in which the grid is initially configured for remain the same.
The Grid has a group as stated in my first post, the issue lies not when the grid is added to the parent form or when its data source is first populated and displayed but rather when the grids data source is reset with a new dataset. The data set fields are the same but can be from a different time period etc..
The existing logic works fine in the older version also listed in the first post, it’s when we upgraded to the new version did we experience the issue.
Hi,
naizen said:why aren't the column widths being retained when I simply repopulate the grid with data?
What exactly do you mean by "repopulate the grid with data?"What you describe here seems to indicate that you are populating the grid once when the applications runs. I don't see anything here about re-populating it or how the column widths would have been set in the first place.
As I mentioned above, if you set the DataSource property on the grid or if you do something which causes your data source to send a Reset notification, then the grid will lose it's layout.
If you are setting up the grid's layout at design-time and you want the layout to be maintained at run-time, then there are certain things you will need to do, and they are detailed here:
HOWTO:How can I define columns in the grid at Design-time and bind them at run-time so that some fields of the data are excluded from the grid?
The grid is created dynamically from metadata stored in tables, when my form is loaded the grid is created and columns widths are set at runtime. After the grid is created\configured, the procedure PopDetailGrid is then called. This procedure populates the grid and clears\adds a group to the grid. The SetDetailColumnWidths procedure is something that was added after the reported issue. That portion should not be taken into consideration; it's something that was added to maintain the column widths after the initial issue was discovered after upgrading to the new version, that being said, the columns widths are never actually being set again when the PopDetailGrid method is called, so my question...why aren't the column widths being retained when I simply repopulate the grid with data? Please let me know if you need more details or my explanation isn’t clear. Appreciate the help.
Brest Regards.
What do you mean by "when the underlying data set is reset"? If you are doing something to the data source that is causing a Reset notification, then the grid will lose it's layout. It has no choice but to do this and I don't see how this could have been different in any other version. Although version 3 is so old, it's possible there was something else going on in that version.
It looks to me like that code you have here is explicitly setting the columns widths. At least I assume that's what the SetDetailColumnWidths method does. I can only guess by the name since you did not include the method code here.
It's really hard to tell anything much from a code snippet like this, since I don't know what half of the method calls do and I don't know when this code is getting called.