Welcome to the Xceed Community | Help
Community Search  

unable to clear items from grid.

Sort Posts: Previous Next
  •  10-06-2008, 3:49 AM Post no. 15900

    unable to clear items from grid.

    Hi this is Md. Masudur Rahman, Software Engineer working for Kaz Software Ltd. .. I have downloaded  latest version of wpf grid. but i am uable to work

    out grid show search resut of data  ... when we creates datarows for first time.. it works fime... but in second time... i had to clear the grid and put all the datarows again...  thats why i called

    "grid.items.clear()"  and it shows me an exception...

     the exception details is given bellow...

    Exception has been thrown by the target of an invocation.

       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

    System.NullReferenceException: Object reference not set to an instance of an object.
       at Xceed.Wpf.DataGrid.DataGridControl.ClearContainerForItemOverride(DependencyObject element, Object item)
       at Xceed.Wpf.DataGrid.DataGridControl.ClearItemContainer(DependencyObject container, Object item)
       at Xceed.Wpf.DataGrid.CustomItemContainerGenerator.RemoveContainer(DependencyObject container, Object dataItem)
       at Xceed.Wpf.DataGrid.CustomItemContainerGenerator.RemoveAllGeneratedItems(IList`1 removedContainers)
       at Xceed.Wpf.DataGrid.CustomItemContainerGenerator.RemoveAllGeneratedItems()
       at Xceed.Wpf.DataGrid.CustomItemContainerGenerator.HandleGlobalItemsReset(Boolean notify)
       at Xceed.Wpf.DataGrid.CustomItemContainerGenerator.HandleGlobalItemsReset()
       at Xceed.Wpf.DataGrid.CustomItemContainerGenerator.OnItemsChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at Xceed.Wpf.DataGrid.CustomItemContainerGenerator.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
       at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
       at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
       at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       at System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
       at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
       at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
       at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       at MS.Internal.Controls.InnerItemCollectionView.RefreshOverride()
       at System.Windows.Data.CollectionView.RefreshInternal()
       at System.Windows.Data.CollectionView.RefreshOrDefer()
       at MS.Internal.Controls.InnerItemCollectionView.Clear()
       at System.Windows.Controls.ItemCollection.Clear()
       at Orbitax.TME.WPF.UIContainer.CrossBorderTaxRate.PopulateGrid(CrossBorderTaxRate[] corprates) in C:\TME Source\Orbitax.TME.WPF.UIContainer\CrossBorderRate\CrossBorderTaxRate.xaml.cs:line 903
       at Orbitax.TME.WPF.UIContainer.CrossBorderTaxRate.GetResult() in C:\TME Source\Orbitax.TME.WPF.UIContainer\CrossBorderRate\CrossBorderTaxRate.xaml.cs:line 649

     

    i am stuck here and unable to proceed...

     

    please help...

     

    Regards

    -------
    Munna

    http://munna.shatkotha.com/blog
    http://munna.shatkotha.com
    www.kaz.com.bd
  •  10-06-2008, 9:04 AM Post no. 15907 in reply to 15900

    Re: unable to clear items from grid.

    If you are binding the source through the ItemsSource property, then you should be reseting the ItemsSource property to provide new data rather than clearing the Items collection.
    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  10-06-2008, 11:56 AM Post no. 15918 in reply to 15907

    Re: unable to clear items from grid.

    you should do this,

    if( datagrid.itemsource!=null)

        datagrid.itemsource=null
     

    and bind the grid again 

    then you should not get the error. 


     

  •  10-07-2008, 1:53 AM Post no. 15929 in reply to 15918

    Re: unable to clear items from grid.

    Hi,

    We are not using binding to item source... we are using all custom cells since we need to do lot of custom stuff in the cell...

     

    we built the grid in the follwing way...

     

    Datarow row = new DataRow();

    then add few 

    DataCell cell = new DataCell();

    row.cells.add(cell);

     then finally add the row in grid's item collection

    grid.items.add(row);

     

    is your suggestion will work for the above case?

     

    please help...

     

     Regards

    -------
    Md. Masudur Rahman

    Software Engineer.

    Kaz Software Ltd.


    http://munna.shatkotha.com/blog
    http://munna.shatkotha.com
    www.kaz.com.bd

  •  10-07-2008, 9:23 AM Post no. 15943 in reply to 15929

    Re: unable to clear items from grid.

    Is your datarow binded to Dataset?

    if yes then in that case above solution will work

    if no then you need to clear all the binding from your grid.

    you can try clearing grid.colums.clear() and wherever u can find clear methods.

    because you are getting this error because binding is still exist in the grid and that's the reason you are getting this error.

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.