Hi Mike,
We have created a dataset with various tables and relations among them and wrapped the object in a BindingSource object before setting as data source of ultra grid object.
Now when we add new row to data tables at run time, InitializeRow gets called twice. Upon looking at call stack for both calls, I could distinguish that one call is raised through BindingSource.ListChanged event and another call is raised through DataView.OnListChanged event. Problem occurs when call through DataView brings in corroupted datarow associated with ultra grid row through ListObject property.
Can you please provide some help?
Is there any way that we can enforce InitializeRow should be called only once?
Thanks in advance
I'm afraid I don't understand the issue. What is this about corruption of the DataRow?
The InitializeRow event is not support to only fire once. It fires quite often, and your code should not make the assumption that it will fire only once. It fires the first time the row is created and any time a value in the row is changed and under several other circumstances, as well. This is the intended behavior.
You may want to check e.ReInitialize if there is some code that you only want to run the first time the row is initialized.
There is no reason why it shouldn't fire many times, infact firing that event would help you to get the latest data,info. available to the user. It is a property of the grid to fire those events for every change in the row.
In all cases, still if you don't wish to happen more than once, after initial firing set a flag and from then on check the flag, but it is not advisable.
Hello,
I think that I need sample that demonstrate this issue in order to be able to investigate this further. Could you please post simple sample that demonstrate your issue and I could run on my machine.
I am waiting for you feedback.
Hello Hristro,
i have checked for the things u have suggested but found no such conditions. let me try to explain my situation further. I have the ultragrid bound to a untyped dataset from the designer. The grid is used for data entry. So upon selected a value on the cell (dropdown) and tabbing out of the cell the AfterCellUpdate event if fired. But this is where the strangeness begins. immediately after exiting the event, it re-enters and repeats this process a further 6 times. and at no time can i see what is firing the event so often.
Some additional info: i have a KeyDown event in which i'm capturing the up down left and right key presses and using them to navigate the cells, e.g.
grd.PerformAction(UltraGridAction.ExitEditMode, false, false); grd.PerformAction(UltraGridAction.NextCellByTab, false, false); e.Handled = true; grd.PerformAction(UltraGridAction.EnterEditMode, false, false);
which would also fire the AfterCellUpdate event. but even so it still repeats 6 more times.
What am i missing here? How can i prevent those extra iterations? Please help ASAP!!!
First thing what you should check is if you have subscribed multiple times for this event (you might subscribed for the event in design time and then in runtime). Second thing that you should check is if you are changing cell value through code (maybe you have some code in IntializeRow event for example which updates cell value and will cause occurring of AfterCellUpdate event).
I hope that this will helps you.
I have a similar problem but with a different event. I seeing where the AfterCellUpdate even is being fired up to 4 times. I tried stepping through the event but it just starts right back at the begining of the event without showing me what was calling the event again. I need to figure this out ASAP. Please help
I'm afraid you lost me. The event fires many times, because that's what it's designed to do. One of the major uses of the InitializeRow event is to apply an appearance to a row or cell based on the contents of a cell. So it fires any time a value in the row changes and also when the row is initialized for the first time.
You don't need to set any flags, there is already a property on the event args called ReInitialize that tells you if the event if firing for the row for the first time or not.