Hi,
It's certainly possible. But this isn't really a function of the grid. What you need is to update your data source. If the data in the data source changes, it will update the grid (assuming your data source supports this). So it depends on what kind of data source you are using.
By DataSource, I meant the DataSource property of the grid - the object that is providing the data to the grid. SQL 2005 is the back end.
You are probably using a BindingSource, DataSet or DataTable as your data source. You should really check out the Microsoft documentation for info on how to use these data objects (if that's what you are using). The question you are asking really doesn't involve the grid, it's a question about the interaction between the back end and the data source.
Apologies, I have found out why the ColumnChanging Event wasn't being raised. I was reassigning the DataSet but not reattached the event handler
Hi Mike,
I have tried handling the DataTable ColumnChanging events but they are never raised. I have also added the following code to the DrawElement method of my custom DrawFilter but the DataRow never contains a proposed version.
if (aCell.Row.ListObject is DataRowView) { DataRow row = ((DataRowView) aCell.Row.ListObject).Row; if (row[aCell.Column.Key, DataRowVersion.Current] is double && row.HasVersion(DataRowVersion.Proposed)) { double newValue = (double)row[aCell.Column.Key, DataRowVersion.Proposed]; double origValue = (double)row[aCell.Column.Key, DataRowVersion.Current]; if (newValue > origValue) { drawParams.AppearanceData.BackColor = Color.LightGreen; } else if (newValue < origValue) { drawParams.AppearanceData.BackColor = Color.Pink; } } }
Do you have any other suggestions how to capture the current cell value and the proposed cell value so that I can compare them and set the cell background according to the direction of change?
Thanks
Jay
Hi Jay,
The grid doesn't fire any events in this case - or at least nothing specific to updates by the data source. The grid, in this case, is the consumer of the event, not the initiator.
You would need to use an event of the DataSource or maybe of the CurrencyManager or the BindingList.
You might be able to use the InitializeRow event of the grid, but this event will fire for a lot of other things, not just an update on the data source.
What grid event is triggered in response to changes to the datasource? I'm using a DataSet. I've added some test code to modify values in my datasource and this does update the values displayed by the grid but no event is fired to notify this. I want to change the background colour when values are updated.