When i rebuild the project in Visual studio 2005 i get the error

"Error 1 The type or namespace name 'Font' could not be found (are you missing a using directive or an assembly reference?) C:\Users\HP_ADMINISTRATOR\Documents\Visual Studio 2005\Projects\Perfume Formula Typing Software\Perfume Formula Typing Software\ 9 17 Perfume Formula Typing Software"
This is the Code:

namespace Perfume_Formula_Typing_Software
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
        private Font m_objFont;
        

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.lblFormulaName = new System.Windows.Forms.Label();
            this.txtFormulaName = new System.Windows.Forms.TextBox();
            this.comboBox1 = new System.Windows.Forms.ComboBox();
            this.lblFormulaType = new System.Windows.Forms.Label();
            this.lblFormulaNumber = new System.Windows.Forms.Label();
            this.txtFormulaNumber = new System.Windows.Forms.TextBox();
            this.btnAdd = new System.Windows.Forms.Button();
            this.lstResult = new System.Windows.Forms.ListBox();
            this.lblItemName = new System.Windows.Forms.Label();
            this.txtItemName = new System.Windows.Forms.TextBox();
            this.lblItemValue = new System.Windows.Forms.Label();
            this.txtItemValue = new System.Windows.Forms.TextBox();
            this.lstResult2 = new System.Windows.Forms.ListBox();
            this.lblTotal = new System.Windows.Forms.Label();
            this.lblSum = new System.Windows.Forms.Label();
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.mnuFileNew = new System.Windows.Forms.ToolStripMenuItem();
            this.mnuFileOpen = new System.Windows.Forms.ToolStripMenuItem();
            this.mnuFileSave = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
            this.mnuFilePageSetup = new System.Windows.Forms.ToolStripMenuItem();
            this.mnuFilePrint = new System.Windows.Forms.ToolStripMenuItem();
            this.mnuFilePrintPreview = new System.Windows.Forms.ToolStripMenuItem();
            this.mnuFileExit = new System.Windows.Forms.ToolStripMenuItem();
            this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
            this.dlgSave = new System.Windows.Forms.SaveFileDialog();
            this.btnRemoveValue = new System.Windows.Forms.Button();
            this.btnRemoveItem = new System.Windows.Forms.Button();
            this.prntDialog = new System.Windows.Forms.PrintDialog();
            this.docPrint = new System.Drawing.Printing.PrintDocument();
            this.objPreview = new System.Windows.Forms.PrintPreviewDialog();
            this.menuStrip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // lblFormulaName
            // 
            this.lblFormulaName.AutoSize = true;
            this.lblFormulaName.Location = new System.Drawing.Point(21, 43);
            this.lblFormulaName.Name = "lblFormulaName";
            this.lblFormulaName.Size = new System.Drawing.Size(78, 13);
            this.lblFormulaName.TabIndex = 0;
            this.lblFormulaName.Text = "Formula Name:";
            // 
            // txtFormulaName
            // 
            this.txtFormulaName.Location = new System.Drawing.Point(105, 40);
            this.txtFormulaName.Name = "txtFormulaName";
            this.txtFormulaName.Size = new System.Drawing.Size(525, 20);
            this.txtFormulaName.TabIndex = 1;
            // 
            // comboBox1
            // 
            this.comboBox1.FormattingEnabled = true;
            this.comboBox1.Items.AddRange(new object[] {
            "Fine Fragrances",
            "Household Products",
            "Personal Care Products",
            "Sub Compounds",
            "Misc RX"});
            this.comboBox1.Location = new System.Drawing.Point(105, 84);
            this.comboBox1.Name = "comboBox1";
            this.comboBox1.Size = new System.Drawing.Size(153, 21);
            this.comboBox1.TabIndex = 2;
            // 
            // lblFormulaType
            // 
            this.lblFormulaType.AutoSize = true;
            this.lblFormulaType.Location = new System.Drawing.Point(21, 87);
            this.lblFormulaType.Name = "lblFormulaType";
            this.lblFormulaType.Size = new System.Drawing.Size(74, 13);
            this.lblFormulaType.TabIndex = 3;
            this.lblFormulaType.Text = "Formula Type:";
            // 
            // lblFormulaNumber
            // 
            this.lblFormulaNumber.AutoSize = true;
            this.lblFormulaNumber.Location = new System.Drawing.Point(276, 87);
            this.lblFormulaNumber.Name = "lblFormulaNumber";
            this.lblFormulaNumber.Size = new System.Drawing.Size(87, 13);
            this.lblFormulaNumber.TabIndex = 4;
            this.lblFormulaNumber.Text = "Formula Number:";
            // 
            // txtFormulaNumber
            // 
            this.txtFormulaNumber.Location = new System.Drawing.Point(369, 84);
            this.txtFormulaNumber.Name = "txtFormulaNumber";
            this.txtFormulaNumber.Size = new System.Drawing.Size(100, 20);
            this.txtFormulaNumber.TabIndex = 5;
            // 
            // btnAdd
            // 
            this.btnAdd.Location = new System.Drawing.Point(569, 159);
            this.btnAdd.Name = "btnAdd";
            this.btnAdd.Size = new System.Drawing.Size(75, 23);
            this.btnAdd.TabIndex = 6;
            this.btnAdd.Text = "Add Item";
            this.btnAdd.UseVisualStyleBackColor = true;
            this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
            // 
            // lstResult
            // 
            this.lstResult.FormattingEnabled = true;
            this.lstResult.Location = new System.Drawing.Point(116, 235);
            this.lstResult.MultiColumn = true;
            this.lstResult.Name = "lstResult";
            this.lstResult.Size = new System.Drawing.Size(344, 329);
            this.lstResult.TabIndex = 11;
            // 
            // lblItemName
            // 
            this.lblItemName.AutoSize = true;
            this.lblItemName.Location = new System.Drawing.Point(21, 126);
            this.lblItemName.Name = "lblItemName";
            this.lblItemName.Size = new System.Drawing.Size(61, 13);
            this.lblItemName.TabIndex = 12;
            this.lblItemName.Text = "Item Name:";
            // 
            // txtItemName
            // 
            this.txtItemName.Location = new System.Drawing.Point(89, 123);
            this.txtItemName.Name = "txtItemName";
            this.txtItemName.Size = new System.Drawing.Size(380, 20);
            this.txtItemName.TabIndex = 13;
            // 
            // lblItemValue
            // 
            this.lblItemValue.AutoSize = true;
            this.lblItemValue.Location = new System.Drawing.Point(503, 126);
            this.lblItemValue.Name = "lblItemValue";
            this.lblItemValue.Size = new System.Drawing.Size(60, 13);
            this.lblItemValue.TabIndex = 14;
            this.lblItemValue.Text = "Item Value:";
            // 
            // txtItemValue
            // 
            this.txtItemValue.Location = new System.Drawing.Point(569, 123);
            this.txtItemValue.Name = "txtItemValue";
            this.txtItemValue.Size = new System.Drawing.Size(100, 20);
            this.txtItemValue.TabIndex = 15;
            // 
            // lstResult2
            // 
            this.lstResult2.FormatString = "N2";
            this.lstResult2.FormattingEnabled = true;
            this.lstResult2.Location = new System.Drawing.Point(457, 235);
            this.lstResult2.Name = "lstResult2";
            this.lstResult2.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
            this.lstResult2.Size = new System.Drawing.Size(72, 329);
            this.lstResult2.TabIndex = 17;
            // 
            // lblTotal
            // 
            this.lblTotal.AutoSize = true;
            this.lblTotal.Location = new System.Drawing.Point(495, 203);
            this.lblTotal.Name = "lblTotal";
            this.lblTotal.Size = new System.Drawing.Size(34, 13);
            this.lblTotal.TabIndex = 19;
            this.lblTotal.Text = "Total:";
            // 
            // lblSum
            // 
            this.lblSum.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.lblSum.Location = new System.Drawing.Point(536, 202);
            this.lblSum.Name = "lblSum";
            this.lblSum.Size = new System.Drawing.Size(108, 22);
            this.lblSum.TabIndex = 20;
            // 
            // menuStrip1
            // 
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.fileToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(712, 24);
            this.menuStrip1.TabIndex = 21;
            this.menuStrip1.Text = "menuStrip1";
            // 
            // fileToolStripMenuItem
            // 
            this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.mnuFileNew,
            this.mnuFileOpen,
            this.mnuFileSave,
            this.toolStripSeparator1,
            this.mnuFilePageSetup,
            this.mnuFilePrint,
            this.mnuFilePrintPreview,
            this.mnuFileExit});
            this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
            this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
            this.fileToolStripMenuItem.Text = "File";
            // 
            // mnuFileNew
            // 
            this.mnuFileNew.Name = "mnuFileNew";
            this.mnuFileNew.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
            this.mnuFileNew.Size = new System.Drawing.Size(146, 22);
            this.mnuFileNew.Text = "&New";
            this.mnuFileNew.Click += new System.EventHandler(this.mnuFileNew_Click);
            // 
            // mnuFileOpen
            // 
            this.mnuFileOpen.Name = "mnuFileOpen";
            this.mnuFileOpen.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
            this.mnuFileOpen.Size = new System.Drawing.Size(146, 22);
            this.mnuFileOpen.Text = "&Open";
            this.mnuFileOpen.Click += new System.EventHandler(this.mnuFileOpen_Click);
            // 
            // mnuFileSave
            // 
            this.mnuFileSave.Name = "mnuFileSave";
            this.mnuFileSave.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
            this.mnuFileSave.Size = new System.Drawing.Size(146, 22);
            this.mnuFileSave.Text = "&Save";
            this.mnuFileSave.Click += new System.EventHandler(this.mnuFileSave_Click);
            // 
            // toolStripSeparator1
            // 
            this.toolStripSeparator1.Name = "toolStripSeparator1";
            this.toolStripSeparator1.Size = new System.Drawing.Size(143, 6);
            // 
            // mnuFilePageSetup
            // 
            this.mnuFilePageSetup.Name = "mnuFilePageSetup";
            this.mnuFilePageSetup.Size = new System.Drawing.Size(146, 22);
            this.mnuFilePageSetup.Text = "Pa&ge Setup";
            // 
            // mnuFilePrint
            // 
            this.mnuFilePrint.Name = "mnuFilePrint";
            this.mnuFilePrint.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P)));
            this.mnuFilePrint.Size = new System.Drawing.Size(146, 22);
            this.mnuFilePrint.Text = "&Print";
            this.mnuFilePrint.Click += new System.EventHandler(this.mnuFilePrint_Click);
            // 
            // mnuFilePrintPreview
            // 
            this.mnuFilePrintPreview.Name = "mnuFilePrintPreview";
            this.mnuFilePrintPreview.Size = new System.Drawing.Size(146, 22);
            this.mnuFilePrintPreview.Text = "Print Pre&view";
            // 
            // mnuFileExit
            // 
            this.mnuFileExit.Name = "mnuFileExit";
            this.mnuFileExit.Size = new System.Drawing.Size(146, 22);
            this.mnuFileExit.Text = "E&xit";
            // 
            // dlgOpen
            // 
            this.dlgOpen.DefaultExt = "pfw";
            this.dlgOpen.Filter = "AndorHuns Formula Worksheet (*.pfw)|*.pfw|All files (*.*)|*.*";
            this.dlgOpen.Title = "Open Perfume Formula";
            // 
            // dlgSave
            // 
            this.dlgSave.DefaultExt = "pfw";
            this.dlgSave.FileName = "Perfume Formula";
            this.dlgSave.Filter = "Andor Huns Formula Worksheet (*.pfw)|*.pfw|All files (*.*)|*.*";
            this.dlgSave.Title = "Save Formula";
            // 
            // btnRemoveValue
            // 
            this.btnRemoveValue.Location = new System.Drawing.Point(417, 158);
            this.btnRemoveValue.Name = "btnRemoveValue";
            this.btnRemoveValue.Size = new System.Drawing.Size(112, 23);
            this.btnRemoveValue.TabIndex = 22;
            this.btnRemoveValue.Text = "Remove Value";
            this.btnRemoveValue.UseVisualStyleBackColor = true;
            this.btnRemoveValue.Click += new System.EventHandler(this.btnRemoveValue_Click);
            // 
            // btnRemoveItem
            // 
            this.btnRemoveItem.Location = new System.Drawing.Point(279, 158);
            this.btnRemoveItem.Name = "btnRemoveItem";
            this.btnRemoveItem.Size = new System.Drawing.Size(89, 23);
            this.btnRemoveItem.TabIndex = 23;
            this.btnRemoveItem.Text = "Remove Item";
            this.btnRemoveItem.UseVisualStyleBackColor = true;
            this.btnRemoveItem.Click += new System.EventHandler(this.btnRemoveItem_Click);
            // 
            // prntDialog
            // 
            this.prntDialog.AllowCurrentPage = true;
            this.prntDialog.AllowSomePages = true;
            this.prntDialog.UseEXDialog = true;
            // 
            // objPreview
            // 
            this.objPreview.AutoScrollMargin = new System.Drawing.Size(0, 0);
            this.objPreview.AutoScrollMinSize = new System.Drawing.Size(0, 0);
            this.objPreview.ClientSize = new System.Drawing.Size(400, 300);
            this.objPreview.Enabled = true;
            this.objPreview.Icon = ((System.Drawing.Icon)(resources.GetObject("objPreview.Icon")));
            this.objPreview.Name = "objPreview";
            this.objPreview.UseAntiAlias = true;
            this.objPreview.Visible = false;
            this.objPreview.Load += new System.EventHandler(this.objPreview_Load);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(712, 583);
            this.Controls.Add(this.btnRemoveItem);
            this.Controls.Add(this.btnRemoveValue);
            this.Controls.Add(this.lblSum);
            this.Controls.Add(this.lblTotal);
            this.Controls.Add(this.lstResult2);
            this.Controls.Add(this.txtItemValue);
            this.Controls.Add(this.lblItemValue);
            this.Controls.Add(this.txtItemName);
            this.Controls.Add(this.lblItemName);
            this.Controls.Add(this.lstResult);
            this.Controls.Add(this.btnAdd);
            this.Controls.Add(this.txtFormulaNumber);
            this.Controls.Add(this.lblFormulaNumber);
            this.Controls.Add(this.lblFormulaType);
            this.Controls.Add(this.comboBox1);
            this.Controls.Add(this.txtFormulaName);
            this.Controls.Add(this.lblFormulaName);
            this.Controls.Add(this.menuStrip1);
            this.Name = "Form1";
            this.Text = "Andor Hun\'s World of Perfumary Formula Worksheet";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label lblFormulaName;
        private System.Windows.Forms.TextBox txtFormulaName;
        private System.Windows.Forms.ComboBox comboBox1;
        private System.Windows.Forms.Label lblFormulaType;
        private System.Windows.Forms.Label lblFormulaNumber;
        private System.Windows.Forms.TextBox txtFormulaNumber;
        private System.Windows.Forms.Button btnAdd;
        private System.Windows.Forms.ListBox lstResult;
        private System.Windows.Forms.Label lblItemName;
        private System.Windows.Forms.TextBox txtItemName;
        private System.Windows.Forms.Label lblItemValue;
        private System.Windows.Forms.TextBox txtItemValue;
        private System.Windows.Forms.ListBox lstResult2;
        private System.Windows.Forms.Label lblTotal;
        private System.Windows.Forms.Label lblSum;
        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem mnuFileNew;
        private System.Windows.Forms.ToolStripMenuItem mnuFileOpen;
        private System.Windows.Forms.ToolStripMenuItem mnuFileSave;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
        private System.Windows.Forms.ToolStripMenuItem mnuFilePageSetup;
        private System.Windows.Forms.ToolStripMenuItem mnuFilePrint;
        private System.Windows.Forms.ToolStripMenuItem mnuFilePrintPreview;
        private System.Windows.Forms.ToolStripMenuItem mnuFileExit;
        private System.Windows.Forms.OpenFileDialog dlgOpen;
        private System.Windows.Forms.SaveFileDialog dlgSave;
        private System.Windows.Forms.Button btnRemoveValue;
        private System.Windows.Forms.Button btnRemoveItem;
        private System.Windows.Forms.PrintDialog prntDialog;
        private System.Drawing.Printing.PrintDocument docPrint;
        private System.Windows.Forms.PrintPreviewDialog objPreview;
        
    }
}

Dani AI

Generated

This error means the compiler cannot see the Font type from the drawing library in the file that contains the declaration. pointed toward the missing namespace import and suggested using the fully qualified type name — both are correct. The important distinction that often trips people is that imports (using directives) are file‑scoped, so adding an import to the editable partial (Form1.cs) does not make that import available inside the auto‑generated designer file.

Quick checklist to diagnose and fix the issue:

  • Open the designer file named in the error and make the drawing type visible to that file (either by adding the appropriate import at the top of that file or by using the full type name in place of the short name).
  • Prefer moving any hand‑written fields or members out of the designer file and into the code‑behind partial class that is intended for manual edits. The designer regenerates its file and can overwrite changes placed there.
  • Verify the project actually references the drawing assembly appropriate for the target framework; remove and re‑add the reference if it looks broken. After changes, do a Clean and then Rebuild.
  • Look for name conflicts: a user‑defined class named the same as the framework type can hide the framework type. Also check that the designer file’s Build Action is set to compile and that there aren’t earlier syntax errors that confuse the compiler.

Best practice: keep custom members in the editable partial file and leave the designer file for generated layout code only. That avoids regeneration surprises and makes namespace/import management predictable. In most cases making the drawing type visible to the designer file or relocating the declaration to the code‑behind resolves the reported error.

Recommended Answers

All 4 Replies

You need a using System.Drawing; at the top of your code (and System.Drawing.dll in your references, if it isn't there).

thanks for the reply. i have using System.Drawing at the top of my code ad System.Drawing.dll in my references but i still get that error about the line i put in red.

Open the file and add namespace entry or type System.Drawing.Font m_objFont;

thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.