Search code examples
c#winformsdevexpressreport

CS1503 ArguCannot convert from 'Tes4.GUI.PrintBill.printBill' to 'System.Windows.Forms.Form'


I have a class for printing (named 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;

        }

    }
}

I don't know what exactly happened to my code after rebuilding it (My last running was good). Here's the code I got an error in my printBill.Designer.cs (this argument)

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

I googled at some topic but it didn't help me at all. I really appreciate your assistance.


Solution

  • Remove this line from the designer file:

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

    The SplashScreenManager constructor overload you're using expects a Form type for the first paramenter. The XtraReport class does not derive from Form, so "this" (an XtraReport) cannot be used:

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

    Source

    If you want to show a waiting screen as your report builds, do it from the form invoking the report, not from the report itself.