发送取消参数C#

时间:2016-01-13 11:31:46

标签: c#

好的,这是我的整个代码。现在...... Detail_BeforePrint()将首先调用,xrPictureBox8_BeforePrint秒。 现在,我想在Detail_BeforePrint事件的e.Cancel = true;内拨打else xrPictureBox8_BeforePrint

 private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
    //here should e.Cancel = true be if it came from xrPictureBox_BeforePrint()
        }

    private void xrPictureBox8_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
    {
        try
        {
            if (xrPictureBox8.ImageUrl.Length > 0) { }
            else
            {
           Detail_BeforePrint(null,[call Cancel parameter]);
            }

        }
        catch (Exception)
        {

        }
    }

1 个答案:

答案 0 :(得分:0)

也许这样的事情会有所帮助吗?

private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
    DoDetail_BeforePrint(e, false);
}

private void DoDetail_BeforePrint(System.Drawing.Printing.PrintEventArgs e, bool cancel)
{
    if (cancel) e.Cancel = true;
    //other things
}

private void xrPictureBox8_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
    try
    {
        if (xrPictureBox8.ImageUrl.Length > 0) { }
        else
        {
            DoDetail_BeforePrint(e, true);
            //or just call e.Cancel = true here?
        }
    }
    catch (Exception)
    {
    }
}