【问题标题】:CS1503 ArguCannot convert from 'Tes4.GUI.PrintBill.printBill' to 'System.Windows.Forms.Form'CS1503 无法从“Tes4.GUI.Print Bill.print Bill”转换为“System.Windows.Forms.Form”
【发布时间】:2019-10-26 11:34:25
【问题描述】:

我有一个打印类(名为 prinBill.cs

using Tes4._3_Tier.DTO;
using System.Collections.Generic;

namespace Tes4.GUI.PrintBill
{
    public partial class printBill : DevExpress.XtraReports.UI.XtraReport
    {

        public printBill()
        {

            InitializeComponent();


        }

        public void InitData(int patient_id, int bill_id, string name_pa, string add, string dob, string sym, string treat, string gender, float Sum,List<bill_ItemDTO> data)
        {
            bill_ID.Value = bill_id;
            patienntID.Value = patient_id;
            patientNName.Value = name_pa;
            patientAdd.Value = add;
            patientTreat.Value = treat;
            patienSym.Value = sym;
            patientDOB.Value = dob;
            Total.Value = Sum;
            patientGender.Value = gender;
            objectDataSource1.DataSource = data;

        }

    }
}

我不知道我的代码在重建后到底发生了什么(我上次运行良好)。这是我在 printBill.Designer.csthis 参数)中遇到错误的代码

this.components = new System.ComponentModel.Container();
this.InitializeComponent();
DevExpress.XtraSplashScreen.SplashScreenManager splashScreenManager1 = new DevExpress.XtraSplashScreen.SplashScreenManager(this, null, true, true);

我搜索了一些主题,但它根本没有帮助我。非常感谢您的帮助。

【问题讨论】:

  • XtraReport 不继承自 System.Windows.Form,因此任何从 XtraReport 继承的实例都不能转换为 System.Windows.Form(就像我让你使用胡萝卜作为信用卡,没有地方会接受)。
  • link,我只是按照本教程进行操作。我上次调试真的很好,但是下次就出错了。很抱歉向您询问解决方案。
  • 我在教程中没有看到您遇到问题的那一行。
  • @LắcLê,请尝试理解 John cmets,您正在尝试从 Windows 窗体继承 XtraReport。 Xtraprint 的 DevExpress 网站有很多示例。请在您的计算机中检查 DevExpress 演示中心 Exe,它与您的 devexpress 安装一起安装。如果不是请在您的系统中安装相关版本并尝试。
  • 我明白约翰的意思。 @John,printBill.designer 的代码是自动生成的。

标签: c# winforms devexpress report


【解决方案1】:

从设计器文件中删除这一行:

DevExpress.XtraSplashScreen.SplashScreenManager splashScreenManager1 = new DevExpress.XtraSplashScreen.SplashScreenManager(this, null, true, true);

您正在使用的 SplashScreenManager 构造函数重载需要第一个参数的 Form 类型。 XtraReport 类不是从 Form 派生的,因此不能使用“this”(一个 XtraReport):

SplashScreenManager(Form parentForm, Type splashFormType, bool useFadeIn, bool useFadeOut)

Source

如果您想在报告生成时显示等待屏幕,请从调用报告的表单中执行,而不是从报告本身。

【讨论】:

  • 你救了我!谢谢你们@Brendon
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多