Hi,
It seems like the AfterRowActivate event fires one extra time when I am first loading my grid. Here is the scenario:
-First I populate a generic List<> object with my data.
-Next I set the data source of my grid to my generic list object.
-At this point I handle the InitializeLayout event of the grid. One of my coding statements is to set the active row of the grid to null.
At this point my "Load" method ends and the grid shows itself. When this happens I am able to set a break point in the AfterRowActivate event of the grid. My code breaks here and there is no call stack to trace back on. The only code listed is the AfterRowActivate event that I am in. I am not sure where this event is being triggered from. It is throwing me off because a row on the grid ends up being activated and selected.
I am not using a binding source, so I don't think it is from the binidng manager activating a row, but I am not sure. Do you know where this last AfterRowActivate event comes from?
Thanks!
Steve
Thanks a lot Mike! I did not know that. I can use that solution then.
sw06226 said:There are situations where the List<> bound to the grid changes. When this happens the grid has to update its values. Therefore, I cannot set SynchWithCurrencyManager to false.
SynchWIthCurrencyManager only affects whether the grid's ActiveRow synchronized with the current Position of the CurrencyManager. It has no effect on the updating of the data.
I am setting the active row to null so that there are no selected/active rows in the grid when it first loads. I am using the grid as part of a user control. I exposed a property on my control that allows a developer to specify that when the grid loads it should automatically select the first row or select nothing. The goal is to allow the developer to just set this property and not have to add any additional code to ensure that nothing is selected/active.
There are situations where the List<> bound to the grid changes. When this happens the grid has to update its values. Therefore, I cannot set SynchWithCurrencyManager to false.
If the currency manager is the issue, do you know how I can listen for this event? Can I access the currency manager that the grid is using? The developer is not using a BindingList<> or a BindingSource, so I can't use either of those to listen for an event.
Thanks,
Hi Steve,
My guess is that you are right, the CurrencyManager (BindingManager) is probably setting it's position to the first row of data and the grid is synchronizing it's ActiveRow.
You could set SynchWithCurrencyManager on the grid to false to stop the grid from synchronizing it's ActiveRow, if you don't need that.
But why set the ActiveRow to null?