Esempio n. 1
0
        // The printing setup function
        private bool Setup(string title)
        {
            var printDialog = new PrintDialog
            {
                AllowCurrentPage = false,
                AllowPrintToFile = false,
                AllowSelection   = false,
                AllowSomePages   = false,
                PrintToFile      = false,
                ShowHelp         = false,
                ShowNetwork      = false
            };

            if (printDialog.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            printDocument = new PrintDocument
            {
                DocumentName        = string.Format("{0} - {1}", Strings.QuickRoute, title),
                PrinterSettings     = printDialog.PrinterSettings,
                DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings
            };
            printDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40);
            printDocument.PrintPage += printDocument_PrintPage;

            dataGridViewPrinter = new DataGridViewPrinter(
                dataGridView,
                printDocument,
                false,
                true,
                title,
                new Font("Calibri", 10, FontStyle.Bold, GraphicsUnit.Point),
                Color.Black,
                false);

            return(true);
        }
        // The printing setup function
        private bool Setup(string title)
        {
            var printDialog = new PrintDialog
                            {
                              AllowCurrentPage = false,
                              AllowPrintToFile = false,
                              AllowSelection = false,
                              AllowSomePages = false,
                              PrintToFile = false,
                              ShowHelp = false,
                              ShowNetwork = false
                            };

              if (printDialog.ShowDialog() != DialogResult.OK)
            return false;

              printDocument = new PrintDocument
                        {
                          DocumentName = string.Format("{0} - {1}", Strings.QuickRoute, title),
                          PrinterSettings = printDialog.PrinterSettings,
                          DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings
                        };
              printDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40);
              printDocument.PrintPage += printDocument_PrintPage;

              dataGridViewPrinter = new DataGridViewPrinter(
            dataGridView,
            printDocument,
            false,
            true,
            title,
            new Font("Calibri", 10, FontStyle.Bold, GraphicsUnit.Point),
            Color.Black,
            false);

              return true;
        }