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
1105
grid within WindowsFormsHost (force data-bind)
posted

Hi,

 

I'm trying to export a grid into a file, before it is visible on the screen.

I've used this method without any problems in .NET 2.0, but when I'm trying the same code on 3.5, where the grid is hosted within a windowsformshost, after settings the datasource:

_grid.DataSource = myDataTable

 

The _grid.Rows attribute and _grid.DisplayLayout.Bands[0].Columns are empty (count = 0)

Only after the grid is displayed on the screen these attributes are set.

Do you know about any problem regarding windowsFormsHost? how can I force  the grid to be updated before showing it on the screen?

  • 469350
    Suggested Answer
    Offline posted

    I don't know anything about WindowsFormsHost, but my guess is that the grid has no BindingContext. If this were on a regular form, I would suggest setting the grid's BindingContext to the Form's BindingContext. If your WindowsFormsHost has a BindingContext, then you should be able to use that just as well. If not, you can simply assign the grid's BindingContext to a new BindingContext and I suspect that will fix it.