Hi, I need the printpreview to reproduce the view of the ultragrid exactly as it is, background colours and all. How can I achieve this? I read in a very old post that it wasn't possible but wanted to know if that's still the case. Attached is an image of my grid and the result of PrintPreview. Thank you.
Public Sub Print_grid(ByVal xGrid As Infragistics.Win.UltraWinGrid.UltraGrid) Try If xGrid.Rows.Count = 0 Then Exit Sub Dim doc As New System.Drawing.Printing.PrintDocument Dim Marg As New System.Drawing.Printing.Margins Marg.Left = 0 Marg.Right = 0 Marg.Top = 0 Marg.Bottom = 30 doc.DefaultPageSettings.Margins = Marg doc.DefaultPageSettings.Landscape = True xGrid.PrintPreview(xGrid.DisplayLayout, doc) Catch ex As Exception MsgBox(ex.Message & " // Print_grid // " & xGrid.FindForm.Name & "." & xGrid.Name) End Try End Sub
Hello,
Thank you for the update. I am glad that you are able to achieve your requirement.
Hello again, Divya
Using InitializeRow to check for the condition that causes the colour change finally did the trick, thank you!
Hello
Divya Jain said:
this.ultraGrid1.Rows[0].Cells[index].Appearance.BackColor = Color.Red ;
this.ultraGrid1.Rows[0].Cells[“column name”].Appearance.BackColor = Color.Red ;
PrintOreview does not replicate the colouring when I add those lines of code. Attached is an image with more info.
To set the background color of the specific row you can pass the row index like this :
this.ultraGrid1.Rows[0].Appearance.BackColor= Color.Green ;
and to set the backcolor of the specific cell of the row set it like this:
Let me know if this helped.
Hello again
No, I don´t know how.
In your example, in InitializeLayout, when you did:
e.Layout.Override.CellAppearance.BackColor = Color.Red
that line of code colours all the rows. But is there a way to colour only the first row? (Only the row whose index is 0?)
Thank you