Reputation: 2520
Let me sketch the situation first: We have an application that monitors file-transfers from & to a fileserver. When the user transfers a/multiple file(s) then the result of the copy is shown in a overview where a Xtragrid-Gridcontrol shows all the files and if the copy was successfull or not.
When de copy was not succesfull then a combobox is shown to choose the desired action (ignore,retry, link,...). This combobox is set using the event CustomRowCellEdit
Code example from that CustomRowCellEdit:
Dim myCb As RepositoryItemLookUpEdit = New RepositoryItemLookUpEdit
myCb.DataSource = GenerateActionlistForDoubleFolder()
myCb.NullValuePrompt = Documentum.Common.Tools.Translate(Tools.Config(m_Docbase), "[SELECT_ACTION]")
myCb.NullText = Documentum.Common.Tools.Translate(Tools.Config(m_Docbase), "[SELECT_ACTION]")
e.RepositoryItem = myCb
The problem:
Larger and larger quatities of files are being copied. the quatities are sometimes that big that the Xtragrid-Gridcontrol
is often still loading when the form is shown (although the datasource has already been set).If the user interacts too soon with xtragrid-gridcontrol (while its still loading) then we get an ArgumentOutOfRangeException
exception of the Xtragrid
. (Due to the datasource of the visual component still changing)
The needed solution:
We should prevent the user to interact with grid while its still loading (seems obivious).
Not working solutions:
The event DataSourceChanged
is being fired when you set the datasource. Not when all rows are loaded.
Simple enabling/disabling the grid everytime the event CustomRowCellEdit
is fired -> Massive performanceloss
Question:
Has anyone encoutered this problem aswell? Is there a fullproof way to detect whether an Xtragrid has completely loaded its datasource (and visualized it)? Or is there a workaround where i don't need to use the CustomRowCellEdit
anymore?
(Solutions from other types of grids are welcome aswell)
Thank you all for your time
Note: Don't ask for more code. The problem doesn't lie in the code, it lies in my usage of the Gridcontrol-Events
Documentation: RowCellEdit
Upvotes: 0
Views: 267
Reputation: 1310
I run into this sometimes in my applications as well. I primarily bind my grids to DataTable
s, and the solution that I've found to work the best is, while your data is loading, to set your gridControl.DataSource
to null/Nothing
and call Application.DoEvents()
. Once the underlying datasource is filled, set the DataSource
back to the source.
The goal of this is to achieve a deterministic way of telling when your data is loaded. Here's a basic example implementation.
myGrid.DataSource = Nothing
Application.DoEvents
FillDataTableWithLoadsOfRows(myDataTable)
myGrid.DataSource = myDataTable
' ...
'Whatever actions to do that require the data to be in the grid
' ...
Upvotes: 1