下面的示例展示了如何预览 XtraGrid 控件。

C#CopyCode image复制代码
private void ShowGridPreview(DevExpress.XtraGrid.GridControl grid) {
   // Check whether the XtraGrid control can be previewed.
   if(!grid.IsPrintingAvailable) {
      MessageBox.Show("The 'DevExpress.XtraPrinting' Library is not found", "Error");
      return;
   }
   // Opens the Preview window.
   grid.ShowPreview();
}
Visual BasicCopyCode image复制代码
Sub ShowGridPreview(ByVal grid As DevExpress.XtraGrid.GridControl)
   ' Check whether the XtraGrid control can be previewed.
   If Not grid.IsPrintingAvailable Then
      MessageBox.Show("The 'DevExpress.XtraPrinting' Library is not found", "Error")
      Return
   End If
   ' Opens the Preview window.
   grid.ShowPreview()
End Sub

下面的插图展示了示例网格控件的预览窗口。