Hi,
I have a data grid that binds to a dataset. When user double click on it row, it opens a modal window which has textbox fields which allow user to update data. The textbox (custom control) and the data grid are data binded to the same DataSet and therefore both would update the same time.
I want to update the gird only if the user close the window. So I used the ultraGrid.BeginUpdate() and EndUpdate() to prevent it from refreshing.
This works fine on my Windows 64 bit machine. However when the QA test this on Win 7 32 bit, the BeignUpdate() stopped the grid(s) from redrawing itself. Here is the screenshot of what happen:
Thanks
I'm afraid you lost me.
BeginUpdate stops the grid from painting itself. That's what it is supposed to do.
So if the problem is that the grid is not painting itself, then that's not a problem - that is the correct behavior.
If the grid is painting itself when BeginUpdate is called, then that might be a problem. But my guess is that it has nothing to do with 32-bit or 64-bit. It's probably related to different painting behavior in different operating systems with options like glass and theming. There are some cases where Windows will send Paint notifications to a window under different circumstances depending on what kinds of options you are using for your system theme.
But it sounds to me like you are simply misunderstanding what BeginUpdate does.
Thanks for the information. I basically misused the BeginUpdate() to achieve a behavior that only works on my machine, can't guarantee it will work with other OS or configuration.
Since there is no other way to defer binding notification, and I cannot use BeginUpdate() to mask the underlining update is there a way for the ultraGrid to NOT respond to the dataset? And follow by a refresh once the data source are updated?
I also don't prefer to unbind and rebind the dataset and the grid.
Since I am not familiar with the concurrency manager, or the binding manager, any guideline or suggestions on how to archive the same behaviors would help.
I've never tried this myself, but you might want to experiment with using a BindingSource. I think you can wrap your DataSet in a BindingSource and bind the grid to the BindingSource, instead of directly to the DataSet.
And I think the BindingSource has a method for suspending the binding notifications.
If the grid get a paint message, it will try to read the data from the BindingSource, though. There's no way around that. But it should stop the grid from updating automatically, I think.
I tried using BindingSourceSuspendBinding() method before . I think it only prevent UI changes applies to the data model, but not the other way around. Does UltraGrid update itself though the BindingSource object, or it update itself by looking directly on what the BindingSource.DataSource?
Also, you are right on that fact that it is the theme I am using. Using Aero theme probably keep a "snapshot" of the underlying grid painting, so that it can generate the aero affect. I tested with "Classic" theme and got painting problem with the grid.
dickysum said:Just wondering, will I get any performance gain from this?
I doubt it. Certainly nothing noticeable.
Thanks for the suggestion. I emailed to the infragistic email support and got the same suggestion... using the picturebox. The picture box to paint over the grid works a lot better than what I was expected. It sounds "hacky", but it is actually a very simple out of the box solution, which I believe it is better than most of the other complicated solution that I had tried.
Just wondering, will I get any performance gain from this?
Thanks for the suggestion. At one point my team has consider that option, but this approach seems to be too "hacky" and my team decided not to go for this approach. There should be a better alternative than using a PictureBox to overlay the grid.
dickysum said:Does UltraGrid update itself though the BindingSource object, or it update itself by looking directly on what the BindingSource.DataSource?
If the grid paints for any reason, it will read the information from the BindingSource. So if you mouse over a cell, you could run into a problem.
Maybe you can achieve what you want another way. What you could do is use the grid's DrawToBitmap method to draw the grid into a Bitmap object. Then hide the grid and show a PictureBox in it's place and assign the bitmap to the PictureBox. That way it will look like the grid is still there and not changing.