DataGridViewExtensionsGetPrintDocument Method
Generates a PrintDocument object for printing the contents of the source DataGridView.
Namespace: DevCase.Extensions.DataGridViewExtensionsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static PrintDocument GetPrintDocument(
this DataGridView dataGridView,
string title = null,
Font textFont = null,
Color headerBackColor = default,
Color headerForeColor = default,
Color rowBackColor = default,
Color rowForeColor = default,
Color rowBackColorAlternate = default,
Color rowForeColorAlternate = default
)
<ExtensionAttribute>
Public Shared Function GetPrintDocument (
dataGridView As DataGridView,
Optional title As String = Nothing,
Optional textFont As Font = Nothing,
Optional headerBackColor As Color = Nothing,
Optional headerForeColor As Color = Nothing,
Optional rowBackColor As Color = Nothing,
Optional rowForeColor As Color = Nothing,
Optional rowBackColorAlternate As Color = Nothing,
Optional rowForeColorAlternate As Color = Nothing
) As PrintDocument
Dim dataGridView As DataGridView
Dim title As String
Dim textFont As Font
Dim headerBackColor As Color
Dim headerForeColor As Color
Dim rowBackColor As Color
Dim rowForeColor As Color
Dim rowBackColorAlternate As Color
Dim rowForeColorAlternate As Color
Dim returnValue As PrintDocument
returnValue = dataGridView.GetPrintDocument(title,
textFont, headerBackColor, headerForeColor,
rowBackColor, rowForeColor, rowBackColorAlternate,
rowForeColorAlternate)
public:
[ExtensionAttribute]
static PrintDocument^ GetPrintDocument(
DataGridView^ dataGridView,
String^ title = nullptr,
Font^ textFont = nullptr,
Color headerBackColor = Color(),
Color headerForeColor = Color(),
Color rowBackColor = Color(),
Color rowForeColor = Color(),
Color rowBackColorAlternate = Color(),
Color rowForeColorAlternate = Color()
)
[<ExtensionAttribute>]
static member GetPrintDocument :
dataGridView : DataGridView *
?title : string *
?textFont : Font *
?headerBackColor : Color *
?headerForeColor : Color *
?rowBackColor : Color *
?rowForeColor : Color *
?rowBackColorAlternate : Color *
?rowForeColorAlternate : Color
(* Defaults:
let _title = defaultArg title null
let _textFont = defaultArg textFont null
let _headerBackColor = defaultArg headerBackColor new Color()
let _headerForeColor = defaultArg headerForeColor new Color()
let _rowBackColor = defaultArg rowBackColor new Color()
let _rowForeColor = defaultArg rowForeColor new Color()
let _rowBackColorAlternate = defaultArg rowBackColorAlternate new Color()
let _rowForeColorAlternate = defaultArg rowForeColorAlternate new Color()
*)
-> PrintDocument
No code example is currently available or this language may not be supported.
- dataGridView DataGridView
-
The DataGridView to print.
- title String (Optional)
-
The title to be printed at the top of the document.
If not provided, the Name property value will be used as the title.
- textFont Font (Optional)
-
Optional. The font to draw header and row texts.
If not provided, the Font property value will be used as the text font.
- headerBackColor Color (Optional)
-
Optional. The background color of the header row.
If not provided, the default color is White.
- headerForeColor Color (Optional)
-
Optional. The text color of the header row.
If not provided, the default color is Black.
- rowBackColor Color (Optional)
-
Optional. The background color of the data rows.
If not provided, the default color is White.
- rowForeColor Color (Optional)
-
Optional. The text color of the data rows.
If not provided, the default color is Black.
- rowBackColorAlternate Color (Optional)
-
Optional. The background color of the alternate data rows.
If not provided, the default color is White.
- rowForeColorAlternate Color (Optional)
-
Optional. text color of the alternate data rows.
If not provided, the default color is Black.
PrintDocument
A
PrintDocument object for printing the contents of the source
DataGridView.
In Visual Basic and C#, you can call this method as an instance method on any object of type
DataGridView. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
This is a code example.
No code example is currently available or this language may not be supported.
Dim headerBackColor As Color = Color.Gray
Dim headerForeColor As Color = Color.White
Dim rowBackColor As Color = Color.LightGray
Dim rowForeColor As Color = Color.LightGray
Dim rowBackColorAlternate As Color = Color.WhiteSmoke
Dim rowForeColorAlternate As Color = Color.WhiteSmoke
Dim printDocument As PrintDocument =
Me.DataGridView1.GetPrintDocument("Title", textFont:=New Font("Arial", 16),
headerBackColor:=headerBackColor, headerForeColor:=headerForeColor,
rowBackColor:=rowBackColor, rowForeColor:=rowForeColor,
rowBackColorAlternate:=rowBackColorAlternate, rowForeColorAlternate:=rowForeColorAlternate)
Dim printPreviewDialog As PrintPreviewDialog = PrintPreviewDialog1
printPreviewDialog.ShowDialog()
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.