private void PSTab_SelectedIndexChanged(object sender, System.EventArgs e) { TabPage tp = PSTab.TabPages[PSTab.SelectedIndex]; if (tp.Controls.Count > 0) { MyPrintControl pc = tp.Controls[0] as MyPrintControl; printPreviewBar1.PrintControl = pc; printPreviewStatus1.PrintControl = pc; //printPreviewBar1.Buttons[4].Pushed = pc.AutoZoom; } }
private void ChangeClickBrick(object sender, EventArgs e) { Brick brick = sender as Brick; if (brick.Value.Equals("Main")) { PSTab.SelectedIndex = 0; return; } int i = brick.Value.Equals(0) ? 1 : 0; brick.Value = i; ((ImageBrick)brick).Image = imageList1.Images[i]; pc.InvalidateBrick(brick); string tpName = "StockRequestEntries ID [" + brick.ID + "]"; if (i == 1) { TabPage tp = new TabPage(tpName); tp.Tag = brick.ID; PSTab.TabPages.Add(tp); PrintingSystem ps = new PrintingSystem(); MyPrintControl pcNew = new MyPrintControl(); pcNew.ChangeClickBrick += new EventHandler(ChangeClickBrick); pcNew.Dock = DockStyle.Fill; pcNew.PrintingSystem = ps; tp.Controls.Add((System.Windows.Forms.Control)pcNew); string queryChild1 = queryChild + brick.ID; dv = CreateDataView(queryChild1, tblChild); //, " WHERE [CustomerID] ='" + brick.ID + "'"); CreateReport(ps, dv, w, schild, null, 0, tpName, imageList2.Images[1]); PSTab.SelectedIndex = FindTabPageIndex(tpName, PSTab); this.Focus(); } else { PSTab.TabPages.RemoveAt(FindTabPageIndex(tpName, PSTab)); PSTab.SelectedIndex = 0; } }