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
490
InitializeLayout fires after InitializeRow
posted

I currently have some logic in the InitializeLayout event that has to execute each time new data is bound to my grid.  My grid's datasource is set to a BindingSource object.  When I first set the data source of my BindingSource, everything works fine.  However, I am then assigning a new object to the my BindingSource's datasource.  At this point neither the InitializeLayout or InitializeRow events fire.  In order to get the InitializeLayout event to fire I am calling the DataBind() method on my grid.  The problem is that after I do this the InitializeRow event is firing before the InitializeLayout event.  I have some processing in InitialzeRow that is dependent upon InitializeLayout firing first.  Is there any way to get InitializeLayout to fire first?

Thanks!

Steve

Parents
  • 469350
    Suggested Answer
    Offline posted

    Hi Steve,

    My guess is that the InitializeRow calls that you get before InitializeLayout fires will be repeated after InitializeLaytout fires, anyway.

    It's always a good idea not to make assumptions about when InitializeRow is going to fire and verify the state you are in. So, for example, if you are adding unbound columns to the grid inside InitializeLayout and referencing those columns inside InitializeRow, you should check the e.Row.Cells.Exists method first to make sure the column is actually there before you try to access it.

Reply Children