Hi,
I am using WinGrid throughout my project all of which I want to be able to export, print, PDF etc. I have created a single Form to do this which I pass the source grid..
Sub LoadUltraGrid(ByVal grdSource As UltraWinGrid.UltraGrid) grdExport = grdSource grdExport.DataBind() grdExport.ResumeLayout() grdExport.Refresh() End Sub
For some reason the WinGrid displays nothing other than the GroupBy bar although if I Watch the WinGrid the rows are there..
Can anyone help?
Thanks
This is probably because your grid has no BindingContext. Try adding the grid to the form's Controls collection before you call DataBind. Or, if that doesn't work, set the grid's BindingContext property to the form's BindingContext.
I've added the code below but still no luck. your suggestion makes sense but I can see the Group By header of the grid so it is there... I just can see anything else
grdExport.BindingContext = Me.BindingContext Me.Controls.Add(grdExport)
You can't really pass an object ByVal. That was my point above. You are passing a reference to the same grid.
I've also try grdExport.Parent = TheExportForm and noticed the original grid on the Source Form has now dissapeared. It's acting like it's being passed ByRef rather than ByVal... ByVal should 'copy' the original grid so any changes aren't updated to the original?!?
It's not a 'reference', I'm passing a grid ByVal and assigning it to another grid on the second form. Both grids have rows if you look at the 'quick watch' but for some reason they aren't being displayed. You are right, the databind etc was just to try and make it work.. my original code was simple GridOnThisForm = GridPassedFromAnotherForm which you would expect to just work. Theres nothing fancy going on anywhere else, it's just a databound grid object being passed to a sub on another form
Can you replicate this? Create 2 forms each with a grid. Make 1 databound from a datasource in the IDE and then try and pass the grid to the second form... would I need to pass the bindingsource as well maybe??
Perhaps I'm not clear on what you are doing, then. Looking at the code you have here, it looks like you are just passing in a reference to an existing grid. So the only way this could happen is if the existing grid already had no rows. Unless there's some code somewhere that's making a copy of the grid that you aren't showing here.
Also, I don't really see the point of calling DataBind, EndUpdate, or Refresh on the grid.I assume you just did that to try to work around the issue.