I have a grid bound to a business object that consists of 2 bands. When the grid is displayed I get the Expand indicator for the second band but the items in the list are always empty even though I know that there are values in the properity fields that should be displayed. So, since I could not figure out why this is working as it is and since I know the values I decided to try to just set them during row initialization. I have code that looks like the following.
tastableGrid.EventManager.AllEventsEnabled = false;TastableOptionalFields optionalFields = t.TastableOptionalFields;foreach (Infragistics.Win.UltraWinGrid.UltraGridCell cell in e.Row.Cells){ String val = optionalFields.GetValue[cell.Column.Key]; //* This returns the value for the specified cell cell.SetValue(val, false); //* I've also tried just setting cell.value=val and tried "ToString" on everything without luck}tastableGrid.EventManager.AllEventsEnabled = true;
Because this is a child band I was not sure if there was some issue with initializerow being fired again for some reason so I
tried the turning all the events off but that didn't make any difference either.
I'm hoping that someone can give me a pointer here as I'm totally confused about why I can't set the value here...I'd actually like to understand why I can't get the items to display properly in the first place since all the columns for the band properties are all displayed but with no values so if anyone has a clue as to why that might be I'd appreciate that.
What I get is the following exception when I try to set one of the values to something other than null (for cases where there really is not a value)
2008-01-13 11:56:47,015 [10] FATAL MyApplication.Program [(null)] - Unhandled thread exceptionSystem.Reflection.TargetException: Object does not match target type. at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value) at Infragistics.Win.UltraWinGrid.UltraGridRow.SetCellValue(UltraGridColumn column, Object val, Boolean suppressErrorMessagePrompt, Boolean throwExceptionOnError) at Infragistics.Win.UltraWinGrid.UltraGridCell.SetValueInternal(Object value, Boolean suppressErrorMessagePrompt, Boolean fireInitializeRow, Boolean throwExceptionOnError) at Infragistics.Win.UltraWinGrid.UltraGridCell.set_Value(Object value) at Infragistics.Win.UltraWinGrid.UltraGridCell.SetValue(Object value, Boolean storeInUndoStatck) at TastingMaster.TastingResultsTable.tastableGrid_InitializeRow(Object sender, InitializeRowEventArgs e) in D:\MyApplication\Source\Master\Master\ResultsTable.cs:line 1387 at Infragistics.Win.UltraWinGrid.UltraGrid.OnInitializeRow(InitializeRowEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.FireEvent(GridEventIds id, EventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.FireInitializeRow(InitializeRowEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGridRow.FireInitializeRow() at Infragistics.Win.UltraWinGrid.RowsCollection.FireInitializeRow(IList rows) at Infragistics.Win.UltraWinGrid.RowsCollection.InitNonGroupByRows(IList fireInitializeRowOnTheseRows) at Infragistics.Win.UltraWinGrid.RowsCollection.SyncRowsHelper(IList boundList) at Infragistics.Win.UltraWinGrid.RowsCollection.SyncRows() at Infragistics.Win.UltraWinGrid.RowsCollection.EnsureNotDirty() at Infragistics.Win.UltraWinGrid.RowsCollection.EnsureFiltersEvaluated() at Infragistics.Win.UltraWinGrid.ScrollCountManagerSparseArray.VerifyAgainstScrollVersion() at Infragistics.Win.UltraWinGrid.RowsCollection.GetVisibleRowCount(IncludeRowTypes includeRowTypes) at Infragistics.Win.UltraWinGrid.UltraGridRow.HasChild(UltraGridBand band, Boolean excludeHidden, IncludeRowTypes includeRowTypes) at Infragistics.Win.UltraWinGrid.UltraGridRow.HasChild(Boolean excludeHidden, IncludeRowTypes includeRowTypes) at Infragistics.Win.UltraWinGrid.PreRowAreaUIElement.DrawForeground(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) at Infragistics.Win.UIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode) at Infragistics.Win.UltraWinGrid.UltraGridUIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode) at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe) at Infragistics.Win.UltraWinGrid.UltraGrid.OnPaint(PaintEventArgs pe) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Hi Neil,
According to the error message here, the grid is not raising the exception. The Eception is being raised by the property descriptor - so that means tha data source itself is blowing up because the field is being set to the wrong data type. So that field must not accept strings.
Ah, and a "hum" as well I guess. What I did, because I could not figure out what was going on and because I wanted more control over what was going on any way, was to build an UltraDataSource from the same business object data fields and used that as the grid data source. I then populated the grid rows in the data source in the same way I was doing it before and it worked ok. I'll look at the property set stuff and see what I did wrong there though.
Thanks for the pointer and the help.