KB Article A17
Visible to All Users

What is the best way to refresh the on-screen data if the datasource is an ArrayList?

Description:
The data is updated externally and the new data is only displayed after its row is clicked on, I don't want to refresh the entire grid as this is inefficient. What is the best way to refresh the on-screen data if the datasource is an ArrayList?

Answer:
The best solution is to implement the IBindingList interface in your data object (please see the GridIBindingList tutorial project). In this case, the XtraGrid is automatically notified of any external changes made.
Otherwise, you should disconnect the grid from its data - set DataSource to null (Nothing in VB.NET) and then bind it again. You can also try to call the BeginSort/EndSort methods of a GridView object.
Another way is to refresh the data by calling the LayoutChanged method of a grid view. For example:

C#
ArrayList data = new ArrayList(); gridControl1.DataSource = data; ... data.Add(myObject); gridControl1.MainView.LayoutChanged();

You will need to explicitly update the CurrencyManager.Position property, when deleting the last row or adding a row to an empty array. Additional information about the IBindingList and CurrencyManager can be found in the MSDN Library.
See Also:
How to resolve the ArgumentOutOfRangeException when deleting an item from the grid's data list
What could be the cause of a serialization error when I save my custom collection which is bound to a grid?

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.