Hi, there:
I am using Infragistics UltraGrid v6.2.2. Inside grid_InitializeRow event handler I have the following line which causes the InitializeRow method called recursively.
UltraGridState s = m_grid.CurrentState;
Eventually, I got stack over flow exception. Can anybody tell me why?
I originally tried to color the cells and force the cells out of edit mode if the cells are in edit mode. The code is as the following:
private void m_grid_InitializeRow(object sender_, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e_)
colorRow(e_.Row);
{
}
This method throws stack over flow exception when I have a lot of rows in the grid. I found out the fault party is: m_grid.CurrentState
Any help is appreciated.
Hi,
Can you explain what you are trying to do here? Whatever it is, I'm pretty sure you are not going about it the right way. It does not make any sense to try to take exit edit mode inside the InitializeRow event.
Hi, Mike:
Thank you very much for the replay.
The reason I am taking exit mode inside IntitializeRow is I have another thread updating the datasource. If a cell is in edit mode the updated data will not be displayed in the cell. Only after the cell existing edit mode the new data will be displayed. I could not find a better place to do it. Could you please tell me the right place to do it?
I'm not sure there is a right place to do it, because I'm really not sure what you are doing. Whenever you introduce a second thread into your application, it makes thing a lot more complex. You are going to need to make sure that you are properly marshalling the data to the UI Thread. It sounds to me like you are trying to force the grid to update it's display without marshalling the data. Or if you are properly marshalling, then maybe that would be the place to refresh the grid and take it out of edit mode.
I'm afraid I can't really give you specifics here because using threads is really very complicated and I find it almost impossible to even discuss it in a forum post like this.
Many people who try to use threading in DotNet don't even realize that they are required to marshal the data and this leads to some serious issues like weird behavior and crashing. I recommend checking out the MS Documentation on threading and marshalling. Start with methods like BeginInvoke and InvokeRequired.
I don't know why that would happen. Maybe the grid is verifying the UIElements so that it can determine the current state.
My original question is whether getting current state casues InitializeRow called. It looks like it is called whenever I getting current state. Could you please clarify it? Thanks.