Daniel Essin
|
|
Group: Forum Members
Posts: 235,
Visits: 309
|
I've got the grid, businessGindingSource and BO mentioned earlier and a data navbar.
I've got this code in the BO:
private void ResultDefs_SetDefaultValues()
{
this.ResultDefId = Guid.NewGuid();
this.OccurrenceValue = 0;
}
When I click add on the data nav bar I get invalid cast errors in the code below both before and after the SetDefaultValues method is executed. I'm confused.
public System.Int32 OccurrenceValue
{
get
{
return (System.Int32)this.CurrentRow["OccurrenceValue"];
}
set
{
this.CurrentRow["OccurrenceValue"] = value;
}
}
public System.Guid ResultDefId
{
get
{
return (System.Guid)this.CurrentRow["ResultDefId"];
}
set
{
this.CurrentRow["ResultDefId"] = value;
}
}
Please help. Thanks,
Dan
|
|
|
Daniel Essin
|
|
Group: Forum Members
Posts: 235,
Visits: 309
|
This exception occurs after the SetDefaultValues event has fired. It's a guid key and I don't have any special null value handling defined in the BO.
This is the exception:
System.InvalidCastException was unhandled by user code
Message="Specified cast is not valid."
Source="BusinessObjectLibrary"
StackTrace:
at DM.Library.ResultDefs.get_ResultDefId() in E:\_work.SF\DM\BusinessObjectLibrary\ResultDefs.Designer.cs:line 300
at DM.Library.ResultDefs.Field_ResultDefId_Descriptor.GetValue(Object component) in E:\_work.SF\DM\BusinessObjectLibrary\ResultDefs.Designer.cs:line 755
at DevExpress.Data.Helpers.BaseListDataControllerHelper.GetRowValue(Int32 listSourceRow, Int32 column)
at DevExpress.Data.DataController.GetRowValue(Int32 controllerRow, Int32 column)
at DevExpress.Data.BaseListSourceDataController.GetRowValue(Int32 controllerRow, Int32 column)
at DevExpress.XtraGrid.Views.Base.ColumnView.GetRowCellValue(Int32 rowHandle, GridColumn column)
at DevExpress.XtraGrid.Views.Grid.GridView.GetRowCellValue(Int32 rowHandle, GridColumn column)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowCellDrawInfo(GridDataRowInfo ri, GridColumnInfoArgs ci, GridCellInfo cell, GridColumnInfoArgs nextColumn, Boolean calcEditInfo)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowCellsDrawInfo(GridDataRowInfo ri, GridColumnsInfo columnsInfo)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcDataRow(GridDataRowInfo ri, GridRow row, GridRow nextRow)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowsDrawInfo()
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcAfterVertScrollCore(Graphics g, Rectangle bounds, Boolean useCache)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcAfterVertScroll(Graphics g, Rectangle bounds, Boolean useCache)
at DevExpress.XtraGrid.Views.Grid.GridView.RefreshRows(Boolean useCache, Boolean afterScroll)
at DevExpress.XtraGrid.Views.Grid.GridView.CalculateDataCore()
at DevExpress.XtraGrid.Views.Grid.GridView.CalculateData()
at DevExpress.XtraGrid.Views.Base.BaseView.CheckViewInfo()
at DevExpress.XtraGrid.Views.Grid.GridView.RefreshRows(Boolean useCache, Boolean afterScroll)
at DevExpress.XtraGrid.Views.Grid.GridView.DoTopRowIndexChanged(Int32 prevTopRowIndex)
at DevExpress.XtraGrid.Views.Grid.GridView.InternalSetTopRowIndex(Int32 newTopRowIndex)
at DevExpress.XtraGrid.Views.Grid.GridView.set_TopRowIndex(Int32 value)
at DevExpress.XtraGrid.Views.Grid.GridView.MakeRowVisibleCore(Int32 rowHandle, Boolean invalidate)
at DevExpress.XtraGrid.Views.Grid.GridView.DoChangeFocusedRow(Int32 currentRowHandle, Int32 newRowHandle, Boolean raiseUpdateCurrentRow)
at DevExpress.XtraGrid.Views.Base.ColumnView.DoChangeFocusedRowInternal(Int32 newRowHandle, Boolean updateCurrentRow)
at DevExpress.XtraGrid.Views.Grid.GridView.DevExpress.Data.IDataControllerValidationSupport.OnCurrentControllerRowChanged()
at DevExpress.Data.CurrencyDataController.OnCurrentControllerRowChanged()
at DevExpress.Data.CurrencyDataController.OnCurrentControllerRowChanging(Int32 oldControllerRow, Int32 newControllerRow)
at DevExpress.Data.CurrencyDataController.set_CurrentControllerRow(Int32 value)
at DevExpress.Data.CurrencyDataController.OnCurrencyManager_PositionChanged(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.CurrencyManager.OnPositionChanged(EventArgs e)
The data of the current row is visible in the attachment. The key field is blank even though the SetDefaultValues event has fired.
The nav bar is a ComponentOne nav bar that seems to be able to use your businesBindingSource as a datasource.
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
What happens if you try to access the ResultDefId property through the watch window? Do you get the same InvalidCastException?
|
|
|
Daniel Essin
|
|
Group: Forum Members
Posts: 235,
Visits: 309
|
Yes. Same error in the watch window.
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
If you put this in the watch window, what is the value? this.CurrentTable.Columns["ResultDefId"].DataType Does it show {System.Guid}?
|
|
|
Daniel Essin
|
|
Group: Forum Members
Posts: 235,
Visits: 309
|
|
|
|
Daniel Essin
|
|
Group: Forum Members
Posts: 235,
Visits: 309
|
OK, I've found the navigator that is embedded in the DevExp grid and have enabled it. When I click its add button I get a different error in:
Protected Overridable Sub OnListChanged(ByVal e As ListChangedEventArgs)
RaiseEvent ListChanged(Me, e)
End Sub
System.IndexOutOfRangeException was unhandled by user code
Message="Index was outside the bounds of the array."
Source="DevExpress.Data.v6.1"
StackTrace:
at DevExpress.Data.VisibleIndexCollection.AddVisibleDataRows(GroupRowInfo rowInfo)
at DevExpress.Data.VisibleIndexCollection.BuildVisibleIndexesEx(GroupRowInfo groupRow, Boolean expandAll, Boolean expanded)
at DevExpress.Data.VisibleIndexCollection.BuildVisibleIndexesEx(GroupRowInfo groupRow, Boolean expandAll, Boolean expanded)
at DevExpress.Data.VisibleIndexCollection.BuildVisibleIndexes(Int32 visibleCount, Boolean allowNonGroupedList, Boolean expandAll)
at DevExpress.Data.DataController.OnBindingListChangedCore(ListChangedEventArgs e)
at DevExpress.Data.CurrencyDataController.OnBindingListChangedCore(ListChangedEventArgs e)
at DevExpress.Data.DataController.OnBindingListChanged(ListChangedEventArgs e)
at DevExpress.Data.CurrencyDataController.RaiseOnBindingListChanged(ListChangedEventArgs e)
at DevExpress.Data.Helpers.ListDataControllerHelper.OnBindingListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
at MicroFour.StrataFrame.Business.BusinessBindingSource.OnListChanged(ListChangedEventArgs e)
at MicroFour.StrataFrame.Business.BusinessBindingSource.BusinessObject_CurrentView_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
at System.Data.DataView.OnListChanged(ListChangedEventArgs e)
This exception occurrs 8 times before ResultDefs_SetDefaultValues() is reached.
|
|
|
Daniel Essin
|
|
Group: Forum Members
Posts: 235,
Visits: 309
|
Please note that this issue is not resolved and that I have been unable to work since last Thursday.
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
I apologize for the slow response, Daniel, Trent and I are both out of town this week. I am not sure what is causing your problem. The row has already been added to the business object's internal DataTable when the ListChanged event is raised, so it should not be throwing an index out of range exception. Without stepping through your application and checking the counts and the CurrentRowIndex within your business object, and determining what index the grid is attempting to access, I am not sure what where the error is coming from. I am going to attempt to test the issue on a DevExpress grid and reproduce the problem.
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
I was able to create a sample and run it without error by using the embedded navigator in the DevExpress GridControl. Something is different about your project... there might be an event handler that you have attached to the grid that is throwing an exception, or there might be some other issue.
|
|
|
Daniel Essin
|
|
Group: Forum Members
Posts: 235,
Visits: 309
|
This is probably something that I need to discuss with you on the phone. It all started out with 2 grids and 2 bo's with a relationship between them. There were so many bizarre things that happened over the course of the past week that it's a little difficult for me to even reconstruct but the basic issue was trying to add a child record in a setting where the parent-child sync was probably not setup right. I will try to call you tomorrow.
Thanks
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
I'm still out of town, and I won't be flying back until Friday, which will take most of the day, so chances of me making it in to the office before Tuesday (Monday is Labor Day) are slim to none. We can continue to try and work out the problem over the forum until then, so, if you would post everything you can think of... exceptions, inner exceptions, behaviours, etc. we might be able to get it solved before I make it back into the office.
|
|
|
Daniel Essin
|
|
Group: Forum Members
Posts: 235,
Visits: 309
|
Attachment for phone call
|
|
|
Daniel Essin
|
|
Group: Forum Members
Posts: 235,
Visits: 309
|
Additional for call:
private void boResultSetDefs_Navigated(MicroFour.StrataFrame.Business.NavigatedEventArgs e)
{
Trace.WriteLine(boResultSetDefs.ResultSetId.ToString());
boResultDefs.FillByParentPrimaryKey(boResultSetDefs.ResultSetId);
}
Output:
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
7613d332-09dd-4fb7-8b01-f5b0374226b9
a5f674f5-9bdb-44b8-a9d3-388757009d76
7613d332-09dd-4fb7-8b01-f5b0374226b9
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
7613d332-09dd-4fb7-8b01-f5b0374226b9
7613d332-09dd-4fb7-8b01-f5b0374226b9
7613d332-09dd-4fb7-8b01-f5b0374226b9
7613d332-09dd-4fb7-8b01-f5b0374226b9
7613d332-09dd-4fb7-8b01-f5b0374226b9
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
a5f674f5-9bdb-44b8-a9d3-388757009d76
7613d332-09dd-4fb7-8b01-f5b0374226b9
7613d332-09dd-4fb7-8b01-f5b0374226b9
7613d332-09dd-4fb7-8b01-f5b0374226b9
7613d332-09dd-4fb7-8b01-f5b0374226b9
|
|
|