We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Problem with binder.layoutcolumns

Hi, i have 2 grids (Header and Detail). For each row in header grid the table/columns of detail grid will change. i.e Some times COL1 and COl2 of one table1 and COL1 and COl2 of another table2 has to be displayed in detail grid. I have used binder.layoutcolumns to filter columns. I tried .Binder.InitializeColumns() .Binder.InternalColumns.Clear() It works fine if i alternatively show the table1 and table2 data. I am having a problem if have to show the same table data. Thanks in advance. Regards, Vamsi.

6 Replies

AD Administrator Syncfusion Team March 19, 2005 09:48 AM UTC

I am not sure I understand. Are you trying to dynamically change the datasource in the second grid as you click rows in the first grid? And things work if the datasource in the second grid is actually changed (the new datasource is different than the old datasource) as you click rows in the first grid, but something is wrong when the new datasource is teh same as the old datasource? Exactly what is wrong? Anyway, you might try calling CurrencyManager.Refresh on the currencymanager for the second grid after you have changed its datasource. Dim cm as CurrencyManager = me.grid2.BindingContext(grid2.DataSource, grid2.DataMember) cm.Refresh();

VK Vamsi Krishna March 21, 2005 01:16 AM UTC

Dear Clay, Thanks for your quick response. I am getting error like "Object reference not set to an instance of an object." Your understanding is correct. I am trying to change the datasource in the second grid. It is working if the datasource is changed or else it is giving the above error when trying to set the header text property. Please find the attached same code. Please let me know if you need more details to debug the problem. If let me know if there are any other better ways to do this. I am using CurrentCellMoved property. Is it ok? Thanks in advance. Regards, Vamsi.

AD Administrator Syncfusion Team March 21, 2005 09:55 AM UTC

Your sample did not upload. Here is a sample that works for me in The 2nd grid changes as you move the current row in the 1st grid, and it seems to work even if you are not changing tables in the 2nd grid on the move. http://www.syncfusion.com/Support/user/uploads/GDBG_2Grids_e6a9035e.zip If you still need to send your sample project, you can email it to support@syncfusion.com and mention this forum thread in the subject line.

VK Vamsi Krishna March 21, 2005 07:00 PM UTC

Hi Clay, There is no problem if binder.layout columns is not used. The example in http://www.syncfusion.com/Support/user/uploads/GDBG_2Grids_e6a9035e.zip is not using binder.layout columns. I am not able to upload the sample code. Please find the code below which is giving problem. In the above example add the following code in the GridDataBoundGrid1_CurrentCellMoved at the end . Try Me.GridDataBoundGrid2.Binder.InitializeColumns() Me.GridDataBoundGrid2.Binder.InternalColumns.Clear() If tableIndicator = 0 Then Me.GridDataBoundGrid2.Binder.LayoutColumns(New String() {"xCol0"}) Me.GridDataBoundGrid2.Binder.InternalColumns("xCol0").HeaderText = "ONE" Else Me.GridDataBoundGrid2.Binder.LayoutColumns(New String() {"xCol1", "xCol0"}) Me.GridDataBoundGrid2.Binder.InternalColumns("xCol1").HeaderText = "TWO" Me.GridDataBoundGrid2.Binder.InternalColumns("xCol0").HeaderText = "ONE" End If Catch ex As Exception MsgBox(ex.Message) End Try Thanks in advance. Regards, Vamsi.

AD Administrator Syncfusion Team March 21, 2005 07:34 PM UTC

Does this work OK for you? http://www.syncfusion.com/Support/user/uploads/GDBG_2Grids_1101e629.zip

VK Vamsi Krishna March 21, 2005 09:49 PM UTC

Simlpy Super. Thanks a lot. It works as per the expectations.

Live Chat Icon For mobile
Up arrow icon