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
1725
Grid exception when setting a cell value in InitialzeRow
posted

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 exception
System.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)