We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Render Style Doesn''t Match "Real" Style

I''m using as a virtual grid. In QueryCellInfo I set e.Style.BaseStyle depending on the underlying cell. Cells are painting correctly, but every now and then when I go into edit mode on a cell, it has the wrong style. For example, the renderer is set to the read-only style when it''s on a read-write cell. I''ve tried doing things like adding a ForceRefresh option in a MoveTo that might be fired. I''ve also tried calling CurrentCell.ForceRefresh() at certain points. None of that seems to force the renderer to the style of the underlying cell. Any ideas? Am I doing something wrong, or is there a way to work around the problem? Btw, the grid is allowing some keystrokes on read-only cells. The behaviour is strange--the first keystroke disappears after the second is made, and only two keystrokes are allowed. I had to specifically set e.Cancel to true in CurrentCellStartEditing to stop read-only cells from being editable.

5 Replies

ML Michael Lenaghan January 29, 2005 07:06 PM UTC

One more bit of info: grid[ row, col ].BaseStyle is also wrong. So it looks like *that* may be the problem, rather than the renderer. The odd thing is that the cell is drawing correctly. So whenever/however the wrong value is being set, it happens after drawing...

AD Administrator Syncfusion Team January 29, 2005 07:10 PM UTC

Can you reproduce this problem in one of our samples, or can you provide a sample project that shows this problem? That way we should be able to debug the code and spot why things are not working propely. You can send it to support@syncfusion.com and mention this thread in the subject line.

ML Michael Lenaghan January 29, 2005 07:28 PM UTC

Actually, I think I now see what''s happening. When the user changes some non-grid info, I reset the "model" behind the virtual grid. When all of the resetting is complete, I grab the data from the server. In between, the model is marked as invalid and returns default values. The problem is that the CurrentCell style is being set before the new model values are fetched. That means the defaults are being used, and it just so happens that the default style is the read-only one. The correct style gets set if the cell goes into and out of edit mode. Is there some other way to force the current cell to do that? CurrentCell.Refresh() doesn''t seem to do the trick; nor does moving the current cell back to itself. Btw: after the new model values are set the grid is invalidated--and the paiting is, in fact, using the correct style. That makes it look like CurrentCell caches something, rather than simply being a pointer to the underlying cell...?

ML Michael Lenaghan January 29, 2005 07:50 PM UTC

Ok, I have a solution now. After getting the new data, and before calling Invalidate(), I call ResetVolatileData(). I was doing this at an earlier point (and I still have to, since not all changes require getting new values from the server) but I now call it again at this other point. That forces CurrentCell to re-load its cached values--in particular, the style of the current cell. Btw, as I mentioned earlier read-only styles are allowing a few keystrokes, though what happens is quite odd.

AD Administrator Syncfusion Team January 29, 2005 07:50 PM UTC

The currentcell does cache information, especially if it is active. In this case, the state information is moved from the style to the renderer, and it is the renderer that controls the look of the cell while it is active. After retrieving your new data, you might try calling grid.RefreshRange(grid.CurrentCell.RangeInfo, true) to see if that will reflect your new styleinformation.

Live Chat Icon For mobile
Up arrow icon