Hi,
I've got a gridview which contains a ListView of GridLayouts. In essence the items are made of SimpleListViewVisualItems very similar to the ListView example found in the demo applications for winforms. Instead of using a StackLayoutPanel for presentation, all data is filled into a GridLayout for easier maintenance and readability. How should I proceed to implement export and print functionality?
I thought of exporting row data to images and exporting those images similar to how it is done in a GridView of ChartElements, but GetAsBitmap returns nothing. Here is the relevant code:
Dim width = column.Width
Dim height = grid.TableElement.ChildRowHeight - 40
Dim radListElement = New RadListViewElement()
Dim gridLayout As GridLayout
Dim gridLayoutElements = New List(Of RadTextBoxElement)
gridLayout = New GridLayout()
gridLayout.StretchHorizontally = False
gridLayout.StretchVertically = False
gridLayout.Columns.Clear()
gridLayout.Rows.Clear()
Dim myFixedWidth = 300
Dim myFixedHeight = 40
gridLayout.Columns.Add(New GridLayoutColumn() With {.SizingType = GridLayoutSizingType.Fixed, .FixedWidth = myFixedWidth})
gridLayout.Columns.Add(New GridLayoutColumn() With {.SizingType = GridLayoutSizingType.Fixed, .FixedWidth = myFixedWidth})
gridLayout.Columns.Add(New GridLayoutColumn() With {.SizingType = GridLayoutSizingType.Fixed, .FixedWidth = myFixedWidth})
gridLayout.Columns.Add(New GridLayoutColumn() With {.SizingType = GridLayoutSizingType.Fixed, .FixedWidth = myFixedWidth})
gridLayout.Rows.Add(New GridLayoutRow() With {.SizingType = GridLayoutSizingType.Fixed, .FixedHeight = myFixedHeight})
gridLayout.Rows.Add(New GridLayoutRow() With {.SizingType = GridLayoutSizingType.Fixed, .FixedHeight = myFixedHeight})
gridLayout.Rows.Add(New GridLayoutRow() With {.SizingType = GridLayoutSizingType.Fixed, .FixedHeight = myFixedHeight})
gridLayout.Rows.Add(New GridLayoutRow() With {.SizingType = GridLayoutSizingType.Fixed, .FixedHeight = myFixedHeight})
gridLayout.Rows.Add(New GridLayoutRow() With {.SizingType = GridLayoutSizingType.Fixed, .FixedHeight = myFixedHeight})
gridLayout.Rows.Add(New GridLayoutRow() With {.SizingType = GridLayoutSizingType.Fixed, .FixedHeight = myFixedHeight})
For x As Integer = 0 To gridLayout.Rows.Count * gridLayout.Columns.Count - 1
Dim child As RadTextBoxElement = CType(GetTextBoxElement(x), RadTextBoxElement)
child.SetValue(GridLayout.RowIndexProperty, x Mod gridLayout.Rows.Count))
child.SetValue(GridLayout.ColumnIndexProperty, CInt(Fix(x / gridLayout.Rows.Count)))
gridLayout.Children.Add(child)
gridLayoutElements.Add(child)
Next
radListElement.Children.Add(gridLayout)
Application.DoEvents()
radListElement.InvalidateMeasure(True)
radListElement.UpdateLayout()
Dim image = radListElement.GetAsBitmapEx(Color.White, 1, New SizeF(width, height))
Dim imageTemp = New RadImageItem()
imageTemp.Image = image
imageTemp.Image.Save(".\test" + i.ToString() + ".png")
row.Cells("someColumn").Tag = imageTemp.Image
i += 1
Private Function GetTextBoxElement(count As Integer) As RadElement
Dim result As New RadTextBoxElement()
Dim myText As String = ""
result.Text = myText
result.StretchHorizontally = True
result.StretchVertically = True
Return result
End Function
I am sure I am missing something, but unsure of what it might be.
Looking forward to your respons