Completed
Last Updated: 05 Sep 2016 17:06 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 01 Sep 2016 13:26
Category: GridView
Type: Bug Report
1
FIX. RadGridView - GridPrintStyle.PrintHierarchy is reset when changing some of the settings in the PrintPreview dialog
To reproduce:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 
    Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products) 
    Me.CategoriesTableAdapter.Fill(Me.NwindDataSet.Categories)

    Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products)
    Me.CategoriesTableAdapter.Fill(Me.NwindDataSet.Categories)
    RadGridView1.AutoGenerateHierarchy = True
    RadGridView1.DataSource = Me.NwindDataSet
    RadGridView1.DataMember = "Categories"
End Sub

Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
    Dim style As New GridPrintStyle()
    style.PrintHierarchy = True
    style.HierarchyIndent = 20
    style.ChildViewPrintMode = ChildViewPrintMode.SelectViewToPrint
    Me.RadGridView1.PrintStyle = style
    Me.RadGridView1.PrintPreview()
End Sub

Please refer to the attached gif file.

Workaround:

Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click

    Me.RadGridView1.PrintSettingsDialogFactory = New CustomGridViewPrintSettingsDialogFactory()

    Dim style As New GridPrintStyle()
    style.PrintHierarchy = True
    style.HierarchyIndent = 20
    style.ChildViewPrintMode = ChildViewPrintMode.SelectViewToPrint
    Me.RadGridView1.PrintStyle = style
    Me.RadGridView1.PrintPreview()
End Sub

Public Class CustomGridViewPrintSettingsDialog
Inherits GridViewPrintSettingsDialog 

    Sub New(document As RadPrintDocument)
        MyBase.New(document)
    End Sub
     
    Protected Overrides Sub LoadSettings()
        MyBase.LoadSettings()

        Dim gridView As RadGridView = TryCast(Me.PrintDocument.AssociatedObject, RadGridView)
        Me.printStyleSettingControl.PrintStyle.PrintHierarchy =gridView.PrintStyle.PrintHierarchy 
    End Sub
End Class

Public Class CustomGridViewPrintSettingsDialogFactory
    Implements IPrintSettingsDialogFactory

    Public Function CreateDialog(document As RadPrintDocument) As Form Implements IPrintSettingsDialogFactory.CreateDialog
        Return New CustomGridViewPrintSettingsDialog(document)
    End Function
End Class
Attached Files:
0 comments