Hi,
i just tried to print a grid via the Print() or PrintPreview() methods.
The grid has 2 unbound colums with string values. These are programmatically filled in the Load() method of the form and after that, the values are displayed in the grid.
When printing the grid, there are no values in the unbound columns any more. The same problem exists when I use the PrintPreview method.
Do you have an idea what could be the problem?
Best regards
When you print the grid, the grid clones it's layout and creates a whole new set of rows for printing. This allows you to modify the print rows or the print layout without affecting the real grid on the screen.
When you call Print or PrintPreview on the grid, there are overloads of these methods which allow you to specify what gets copied over from the real grid rows to the print rows. So my guess is that you chose not to copy anything over and so the values that you populated the unbound cells with were lost.
So one way to fix this is to use an overload of the method that copies over the values.
Another option, which is probably more efficient is to populate your unbound column using the InitializeRow event. This alleviates the need to loop through all the rows and the event will fire both for the on-screen rows and then again for the print rows.
I removed the 2 unbound columns from the grid and added them to the DataSet which is bound to the grid. In this case it made no difference for me.
Now the columns appear at the print page and at the preview.
I have never had problems with unbound columns before. The only difference I noticed to my other projects was that i had to use an ODBC connection to a Gupta SqlBase DB and when dragging tables into the DataSet, double quotes were added to all column names. Maybe that caused problems.
Anyway, the problem is solved for me.
Thanks for your help.
Hello,
I am not sure why you are getting empty Page after Printing but I have tried to assign a simple dataSource in the load event of the Form, after that create the Unbound columns in the InitializeLayout event of the Grid and than populate them in the InitializeRow event. After that the printing works as expected. If this approach is not suitable for your scenario please provide us small sample demonstrating this behavior and we will be glad to take a look at it.
Sincerely,
Danko
Developer Support Engineer
Infragistics
www.infragistics.com/support