question

PavithraMadushini-2196 avatar image
0 Votes"
PavithraMadushini-2196 asked TimonYang-MSFT answered

The variable 'crystalReportViewer1' is either undeclared or was never assigned.

 namespace POSBunifu
 {
     partial class frmInvoice
     {
    
         private System.ComponentModel.IContainer components = null;
    
         protected override void Dispose(bool disposing)
         {
             if (disposing && (components != null))
             {
                 components.Dispose();
             }
             base.Dispose(disposing);
    
         }
    
         #region Windows Form Designer generated code
    
         private void InitializeComponent()
         {
             this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
             this.SuspendLayout();
    
             this.crystalReportViewer1.ActiveViewIndex = -1;
             this.crystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
             this.crystalReportViewer1.Cursor = System.Windows.Forms.Cursors.Default;
             this.crystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
             this.crystalReportViewer1.Location = new System.Drawing.Point(0, 0);
             this.crystalReportViewer1.Name = "crystalReportViewer1";
             this.crystalReportViewer1.SelectionFormula = "";
             this.crystalReportViewer1.ShowCloseButton = false;
             this.crystalReportViewer1.ShowExportButton = false;
             this.crystalReportViewer1.ShowGotoPageButton = false;
             this.crystalReportViewer1.ShowGroupTreeButton = false;
             this.crystalReportViewer1.ShowPageNavigateButtons = false;
             this.crystalReportViewer1.ShowRefreshButton = false;
             this.crystalReportViewer1.ShowTextSearchButton = false;
             this.crystalReportViewer1.Size = new System.Drawing.Size(819, 486);
             this.crystalReportViewer1.TabIndex = 1;
             this.crystalReportViewer1.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None;
             this.crystalReportViewer1.ViewTimeSelectionFormula = "";
    
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(819, 486);
             this.Controls.Add(this.crystalReportViewer1);
             this.Name = "frmInvoice";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "Receipt";
             this.Load += new System.EventHandler(this.frmInvoice_Load);
             this.ResumeLayout(false);
    
         }
    
         #endregion
    
         private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
     }
 }


Error shows on this line > this.Controls.Add(this.crystalReportViewer1);

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TimonYang-MSFT avatar image
0 Votes"
TimonYang-MSFT answered

The code looks fine, but the problem does exist, and I can reproduce it.

But when I replace this control with any other control, the problem disappears.

I'm not sure if it is the designer's problem or some code inside this control that caused this problem. Check the similar problems in these links first to see if someone's solution is right for you.

The variable 'control' is either undeclared or was never assigned - Except it is, and the application compiles

The variable '<control_name>' is either undeclared or was never assigned.

The variable 'variable_name' is either undeclared or was never assigned

If nothing works, please describe what you want to use this control to achieve, and then we can try to use other alternative controls to do it.

This package has not been updated since 2014. Even if we find some problems with this package, we cannot get the update anymore.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.