Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hi,

                                    I have a grid with exiting columns and it is binded to a dataset using BindingSource.

                                    I have cases when there may be a change in schema of dataset and need to reflect newer columns in the grid.

                                    I am using CurrencyManager_MetaDataChanged event and evaluating whether a newer column exists in dataset. If found i add the column to grid.

                                    It throws following errror when i am trying to achive this.

                                    System.InvalidCastException was unhandled
                                      Message="Unable to cast object of type 'System.Data.DataRowView' to type 'System.Data.DataViewManagerListItemTypeDescriptor'."
                                      Source="System.Data"
                                      StackTrace:
                                           at System.Data.DataTablePropertyDescriptor.GetValue(Object component)
                                           at DevExpress.Data.Helpers.ListDataControllerHelper.DevExpress.Data.IRelationList.GetDetailList(Int32 listSourceRow, Int32 relationIndex)
                                           at DevExpress.Data.Helpers.ListDataControllerHelper.DevExpress.Data.IRelationList.IsMasterRowEmpty(Int32 listSourceRow, Int32 relationIndex)
                                           at DevExpress.Data.DataController.IsDetailRowEmpty(Int32 controllerRow, Int32 relationIndex)
                                           at DevExpress.Data.DataController.IsDetailRowEmptyCached(Int32 controllerRow, Int32 relationIndex)
                                           at DevExpress.XtraGrid.Views.Grid.GridView.IsMasterRowEmptyCached(Int32 rowHandle)
                                           at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CreateRowInfo(GridRow row)
                                           at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowsDrawInfo()
                                           at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcGridInfo()
                                           at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.Calc(Graphics g, Rectangle bounds)
                                           at DevExpress.XtraGrid.Views.Base.ColumnView.DoInternalLayout()
                                           at DevExpress.XtraGrid.Views.Base.ColumnView.CalculateLayout()
                                           at DevExpress.XtraGrid.Views.Grid.GridView.LayoutChanged()
                                           at DevExpress.XtraGrid.Views.Base.ColumnView.OnColumnVisibleIndexChanged(GridColumn column)
                                           at DevExpress.XtraGrid.Columns.GridColumn.set_Visible(Boolean value)
                                           at DevExpress.XtraGrid.Columns.GridColumnCollection.AddVisible(String fieldName)
                                           at DevExpress.XtraGrid.Columns.GridColumnCollection.AddVisible(String fieldName, String caption)
                                           at WindowsFormsApplication7.Form1.CurrencyManager_MetaDataChanged(Object sender, EventArgs e) in D:\Shatru Singh\Documents\Visual Studio 2008\Projects\WindowsFormsApplication7\WindowsFormsApplication7\Form1.cs:line 49
                                           at System.Windows.Forms.CurrencyManager.OnMetaDataChanged(EventArgs e)
                                           at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
                                           at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
                                           at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
                                           at System.Windows.Forms.BindingSource.ResetBindings(Boolean metadataChanged)
                                           at System.Windows.Forms.BindingSource.SetList(IList list, Boolean metaDataChanged, Boolean applySortAndFilter)
                                           at System.Windows.Forms.BindingSource.ResetList()
                                           at System.Windows.Forms.BindingSource.set_DataMember(String value)
                                           at WindowsFormsApplication7.Form1.simpleButton1_Click(Object sender, EventArgs e) in D:\Shatru Singh\Documents\Visual Studio 2008\Projects\WindowsFormsApplication7\WindowsFormsApplication7\Form1.cs:line 84
                                           at System.Windows.Forms.Control.OnClick(EventArgs e)
                                           at DevExpress.XtraEditors.BaseButton.OnClick(EventArgs e)
                                           at DevExpress.XtraEditors.BaseButton.OnMouseUp(MouseEventArgs e)
                                           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
                                           at System.Windows.Forms.Control.WndProc(Message& m)
                                           at DevExpress.Utils.Controls.ControlBase.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
                                           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
                                           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
                                           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
                                           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
                                           at System.Windows.Forms.Application.Run(Form mainForm)
                                           at WindowsFormsApplication7.Program.Main() in D:\Shatru Singh\Documents\Visual Studio 2008\Projects\WindowsFormsApplication7\WindowsFormsApplication7\Program.cs:line 18
                                           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
                                           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
                                           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
                                           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
                                           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
                                           at System.Threading.ThreadHelper.ThreadStart()
                                      InnerException:

                                    Thanks in advance

                                    Shatru

                                    Steps to Reproduce:

                                    Please use the attached project to reproduce the error

                                    Actual Results:

                                    Application crashes

                                    Expected Results:

                                    It shouls show the newly added column

                                WindowsFormsApplication7.zip
                                0

                                Hi Shatru,

                                The XtraGrid doesn't support this scenario. The grid obtains property descriptors to access data, when you assign a datasource to it. It can't modify this collection later on, if you modify the datasource schema. To make the grid update its property descriptors, set the grid datasource to Null, and again to the updated datasource. I have modified your project accordingly. It is attached. Please let us know if this makes sense.

                                Thanks,
                                Michael.

                                B143657.zip
                                0

                                Thanks a ton Michael,

                                The woraround works great for me.

                                Shatru

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners