"不包含定义且未找到扩展方法"但存在于另一类

时间:2017-09-02 20:17:52

标签: c# winforms printing print-preview printdialog

我收到此错误:

  

TicketingSystem'不包含' DVPrintDocument_PrintPage'的定义并且找不到任何扩展方法。

我试图通过将代码放在单独的类中来组织我的代码。我创建了一个名为Printing.cs的新类,其中包含以下代码:

public void DVPrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
    Bitmap r3tsLogo = Properties.Resources.rt3slogo;
    Image image1 = r3tsLogo; //image 1 is r3tsLogo
    e.Graphics.DrawImage(image1, 350, 0, image1.Width, image1.Height);

    // e.Graphics.DrawString("Employee Name:" + employee.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 200)); //Put to bottom of paper
    e.Graphics.DrawString("Address:", new Font("Impact", 12, FontStyle.Regular), Brushes.Black, new Point(300, 90));//change the new point to put text on different part of paper.
    e.Graphics.DrawString("North Building", new Font("Arial", 10, FontStyle.Regular), Brushes.Black, new Point(370, 94)); //This line of code connects to Code line 151   
    e.Graphics.DrawString("Email:", new Font("Impact", 12, FontStyle.Regular), Brushes.Black, new Point(300, 120));//change the new point to put text on different part of paper.
    e.Graphics.DrawString("email@email.com", new Font("Arial", 10, FontStyle.Regular), Brushes.Black, new Point(350, 124)); //This line of code connects to Code line 154
    e.Graphics.DrawString("Date: " + DateTime.Now, new Font("Arial", 13, FontStyle.Regular), Brushes.Black, new Point(300, 150));
    e.Graphics.DrawString(ticketingSystem.dashes.Text, new Font("Arial", 12), Brushes.Black, new Point(0, 160));

    e.Graphics.DrawString("CUSTOMER INFORMATION:", new Font("Arial", 14, FontStyle.Regular), Brushes.Black, new Point(275, 180));
    e.Graphics.DrawString("Customer Name:" + ticketingSystem.nameTxtB.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 200));
    e.Graphics.DrawString("Email:" + ticketingSystem.emailTxtBox.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 230));
    e.Graphics.DrawString("Cell Number:" + ticketingSystem.cellNumberTxtB.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 260));


    if(ticketingSystem.studentRadioB.Checked == true)
    {
        e.Graphics.DrawString("Position:" + ticketingSystem.studentRadioB.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 290));
    }
    else if (ticketingSystem.teacherRadioB.Checked == true)
    {
        e.Graphics.DrawString("Position:" + ticketingSystem.teacherRadioB.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 290));
    }

    e.Graphics.DrawString(ticketingSystem.dashes.Text, new Font("Arial", 12), Brushes.Black, new Point(0, 350));

    //--------------------------------------Device Information -------------------------------------------------------------------------------------
    int y = 493;

    e.Graphics.DrawString("DEVICE INFORMATION:", new Font("Arial", 14, FontStyle.Regular), Brushes.Black, new Point(286, 373));


    e.Graphics.DrawString("Device Type:" + ticketingSystem.devices.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 403));

    if (ticketingSystem.devices.Visible == true & ticketingSystem.devices.Text == "Console")
    {
        e.Graphics.DrawString("Type of Console:" + ticketingSystem.consoleTextBox.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 433));
    }

    if (ticketingSystem.comboBox3.Visible == true) //iphone selection box is visible then show selected model on print document
    {
        e.Graphics.DrawString("Type of Phone:" + ticketingSystem.comboBox3.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 433));

    }


    e.Graphics.DrawString("Service Type:" + ticketingSystem.serviceDesc.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 463));

    using (var arial15 = new Font("Arial", 15, FontStyle.Regular))
    {
        y += DrawWrapped("Price: $" + Convert.ToInt32(cPrice), arial15, new Point(50, 493), e.PageBounds.Size, e.Graphics);
    }

    using (var arial15 = new Font("Arial", 15, FontStyle.Regular))
    {
        y += DrawWrapped("Description:" + ticketingSystem.description4Repair.Text, arial15, new Point(50, y), e.PageBounds.Size, e.Graphics);
    }
}

现在当我在Main.cs中评论所有内容时,我得到了同样的错误:

  

TicketingSystem'不包含' DVPrintDocument_PrintPage'的定义并且找不到任何扩展方法。

我想要做的就是告诉我的designer.cs在Printing.cs中查找代码。

0 个答案:

没有答案
相关问题