Hi all,I am currently facing a strange problem with the WinGrid.It is a standard WinGrid, bound to an object datasource (List<item>).I added an UnboundColumn to display a "light" icon that indicates its status (red, green).On InitializeRow the calculation is done and a predefined (for reuse) Appearance is assigned to the cell (unbound column).Now imagine the following rows (Id, IndicatorImage):1 green2 green3 red4 red
now if I remove the data entry from the datasource that contains Id = 2 I assumed to have the following rows:1 green3 red4 red
Unfortunately I get this:1 green3 green4 red
It seems that the indicator image stays the same for the rows (the bottom one is removed though)
Any hint is kindly appreciated,best regardsAndy
Hi Mike,
the GetCountFromItem function is actually accessing the ListObject of the row, reads one property and then checks the database for related information.So it is not directly accessing child nodes. What it does is to use Entity Framework to check the information necessary for the "count" context.paymentsDue.Count(w => w.BookingId == entry.BookingId) where entry is the casted ListObject
Anyway, it still might be a timing issue as you mentioned, because currently it initializes one entity context per call to InitializeRow, which is of course not perfect.Here is where the buffering should come into account, but I am still working on it.
When this part of the application is optimized I can easily uncomment the solution you had to fix this and see if it still works... and of course let you know about the outcome if you are interested. This will all happen within this week, so everything will be fresh in my mind ;)
CheersAndy
Hi Andy,
Okay, I'm glad it's working, now. That seems to confirm my suspicion that this is some kind of timing issue.
What is GetCountFromItem doing? I'm guessing that maybe this method is not just accessing fields directly on the row's ListObject, but is also accessing child rows or some other related rows and those rows haven't been updated at the time the InitializeRow event fires.
Hi Mike,i checked out your solution and it works fine. The grid.Rows.Refresh(RefreshRow.FireInitializeRow) did the magic, which was expected if the Initialize_Rows is fired again.I am still wondering why this didn't work upon removal of the entry from the data-source, but so far this will suit my needs.
If I find the time I will put together a sample to check if this only happens within the current project or if it is somehow reproduce able.
Thanks a lot Mike for your help and have a great week,best regardsAndy
Okay, let me know how it goes.
Hi Mike,thanks a lot for your reply, I am going to test what you proposed and let you know how it worked out.Unfortunately I will be able to do this at the earliest of Monday.
I didn't implement the Update/Refresh because I could see the entry disappear from the list upon removal and I didn't even recognize the problem until the testers could get a hand on it..
I just have one concern regarding this, because the routine for GetCountFromItem is quite heavy weighted, but I am pretty sure if this approach works I can implement buffering or anything alike to make this less heavy.
By the way, I do not use threads in this project, so this shouldn't interfere with the grid.
Thanks again Mike and have a great weekendbest regardsAndy