Hi,
I have a grid and a string column in it. If the value is not Empty I will set the Style to Button else to Default.
The reason is the string defines the text of the button an an empty string meants no button.
so long no real problem.
i use a BindingList<> as Datasource
if the value of the string changes (also some other things in the grid change) the new value is drawn in the grid.
That's fine.
But the
AfterCellUpdate, AfterRowUpdate and also the AfterRowInsert Event is not fiering.but the Cell Value Change and a "child" row is added.
So I'm looking for a event that indicates the BindingList<> has changed and is new displayed. At the moment I use the Paint event ... it woks cause i have a very small grid but I think this is no good way.
Is there a event on the grid that I can use? In what cases does the value of a cell changed whitout firing a AfterCellUpdate event.
Or is there something else to change the style of a cell depending on the content of the cell?
Thanks
Wolfgang
Hi Wolfgang,
The InitializeRow event is perfect for what you want here. It fires the first time the row is created and also any time a value in the row changes.
Hi Mike,
thanks the InitializeRow is perfect for insert an update. But if I loos a row (cause the element is remove from Bindiglist) it do not fire. What I think probertly make sence.
Return to my Problem I have a Bindinglist of Typa A that is the DataSource of my Grid.
A has a Bindinglist of Type B as Property
B has a Bindinglist of Type C as Property
On code I Change the Elements B and C and add or remove them from there BindingList in A und B.
By the way the InitializeRow only fire if A, B and C implements INotifyPropertyChanged
At the moment I get the ListChanged of my first Bindinglist (of type A) and do there my Code cause i dont know what Event is fired if I remove a Element of the BindingList in A of Type B.
The row disapears as expected but what Event is Cause if a row is Deleted? Its not AfterRowsDeleted.
Any Idea what Event is Fired in this case? My current way works as well, but i woud like to let the Format be done by the sourounding source and not by my logic class,
Wolfgang77 said:By the way the InitializeRow only fire if A, B and C implements INotifyPropertyChanged
It was not clear to me from your original post that you were changing the data on the data source and not through the grid. But you are correct - you have to implement INotofyPropertyChanged in order for the DotNet BindingManager to know that something changed and to send the proper ListChanged notifications to the grid.
Wolfgang77 said: At the moment I get the ListChanged of my first Bindinglist (of type A) and do there my Code cause i dont know what Event is fired if I remove a Element of the BindingList in A of Type B. The row disapears as expected but what Event is Cause if a row is Deleted? Its not AfterRowsDeleted. Any Idea what Event is Fired in this case? My current way works as well, but i woud like to let the Format be done by the sourounding source and not by my logic class,
No event of the grid is fired in this case. The grid is responding to an event notification from the BindingManager here. It's a listener to an event here, not the trigger.
It sounds to me like you need to be responding to events of the BindingManager or BindingList and then refresh the grid using the grid.Rows.Refresh method.
Thanks.
I now use the RowInizialize from the Grid and the ListChange from the BindingList. With this I catch all my cases.