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
440
InitializeLayout was not fired.
posted

Hi,

I set DataTable as DataSource to UltraGrid. I add new columns and rows into DataTable,  After that I set this DataTable as DataSource to UltraGrid  again. InitializeLayout was not fired. I need to fire   InitializeLayout in this case. How I make It?

Thanks.

  • 875
    Offline posted

    I had the same problem I think and found this post. In case this happens to help somebody else out, I was setting the UltraGrid Datasource directly to a DataSet. Once I changed this to bind with a BindingSource, InitializeLayout then started firing:

    VB.Net:

    .DataSource = Nothing
    .DataSource = New BindingSource(myDataset, String.Empty)

  • 469350
    Offline posted

    Hi,

    Why do you need to re-fire InitializeLayout?

    If you set the grid's DataSource to the same object it is already set to, the grid will ignore this, since nothing has changed.

    When you add tables or rows to a DataTable, the DataTable will automatically notify the grid of the changes and the grid will update itself to display the new columns or rows. So you don't have to do anything to make this happen.

    If you want to make changes to the grid layout, you could simple make the changes outside of the InitializeLayout event.

    Or... you could move your InitializeLayout code into a method and then call that method from InitializeLayout and also call that same method when your data source changes.