Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
UltraGrids and BindingSources: First Row and DataSourceChanged
posted

Hello,

I have two questions about using the UltraGrids with a BindingSource.

Firstly, why is the first row automatically made active after binding the bindingsource as the grid's datasource? I don't like this functionality, because strangely enough the Position- or CurrentChanged is not called when this row is automatically selected.

This causes the CurrentChanged event not to be fired when a user actually clicks (and selects/makes active) that first row. In order to get around this issue, I have bound the AfterRowActivate event and I unbind it the first time it has fired. In the event code I check whether the Position of the BindingSource = 0 and if it is, I fire the CurrentChanged event myself.

This is really annoying; is there any other way around this? I would like it i the first row doesn't become active automatically, but the CurrentChanged event would still be fired if the first row is made active.

 

Secondly, why doesn't the UltraGrid have a DataSourceChanged event or something like that? I really need it, but I can't find anything in the API.

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Davio said:
    Firstly, why is the first row automatically made active after binding the bindingsource as the grid's datasource? I don't like this functionality, because strangely enough the Position- or CurrentChanged is not called when this row is automatically selected.

    The CurrencyManager in DotNet does this, it's nothing to do with the grid. The grid responds to this by synchronizing it's ActiveRow with the current position of the CurrencyManager, though. You can turn this off, if you like, by setting SyncWithCurrencyManager on the grid to false.

    Davio said:
    Secondly, why doesn't the UltraGrid have a DataSourceChanged event or something like that? I really need it, but I can't find anything in the API.

    Events are typically used by the developer to detect user actions which you would not otherwise be able to detect. Since the user cannot set the DataSource on the grid, the only way the DataSource can be changed is if you change it in code. And since you know you did so, you don't need an event to tell you that this happened. I recommend adding a method somewhere and always setting the DataSource on the grid through that method. That way, you can always trap when a change occurs.

Children