Exemplo n.º 1
0
        private void printButton_Click(object sender, EventArgs e)
        {
            try
            {
                streamToPrint = new StreamReader("C:\\MyFile.txt");
                try
                {
                    //var pd = new PrintDocument();
                    //pd.PrintPage += PdPrintPage;
                    //pd.Print();

                    var gridControlBase = new GridControlBase();
                    var gpd             = new GridPrintDocument(gridControlBase);
                    gpd.PrintPage += PdPrintPage;

                    gpd.Print();
                }
                finally
                {
                    streamToPrint.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        public override void InvokeAction(object sender, EventArgs e)
        {
            GridControlBase grid = ActiveGrid;

            if (grid != null)
            {
                try
                {
                    GridPrintDocument pd = new GridPrintDocument(grid); //Assumes the default printer

                    if (PrinterSettings.storedPageSettings != null)
                    {
                        pd.DefaultPageSettings = PrinterSettings.storedPageSettings;
                    }

                    PrintDialog dlg = new PrintDialog();
                    dlg.Document       = pd;
                    dlg.AllowSelection = true;
                    dlg.AllowSomePages = true;
                    DialogResult result = dlg.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        pd.Print();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occurred attempting to preview the file to print - " + ex.Message);
                }
            }
        }
Exemplo n.º 3
0
        //used to display the print dialog
        private void buttonAdv4_Click(object sender, EventArgs e)
        {
            GridPrintDocument pd          = new GridPrintDocument(this.gridGroupingControl1.TableControl);
            PrintDialog       printDialog = new PrintDialog();

            printDialog.Document             = pd;
            pd.DefaultPageSettings.Landscape = true;
            if (printDialog.ShowDialog() == DialogResult.OK)
            {
                pd.Print();
            }
        }
Exemplo n.º 4
0
        private void printButton_Click(object sender, EventArgs e)
        {
            try
            {
                streamToPrint = new StreamReader("C:\\MyFile.txt");
                try
                {
                    //var pd = new PrintDocument();
                    //pd.PrintPage += PdPrintPage;
                    //pd.Print();

                    var gridControlBase = new GridControlBase();
                    var gpd = new GridPrintDocument(gridControlBase);
                    gpd.PrintPage += PdPrintPage;

                    gpd.Print();
                }
                finally
                {
                    streamToPrint.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }