找不到行的命名空间类型

the type of namespace of rows could not be found

我收到如下错误:

the type of namespace of rows could not be found

这是我的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;


namespace DataGridView1
{
    public partial class Cust_Form : Form
    {
        public Cust_Form()
        {
            InitializeComponent();
        }


        private void DataGridView1_Load(object sender, DataGridViewCellEventArgs e)
        {

            dataGridView.Rows.Add("1", "Mei", "US");
            dataGridView.Rows.Add("2", "Wei", "US");
        }

        //private void Cust_Form_Load(object sender, EventArgs e)
        //{

        //}
    }
}

我应该添加什么命名空间来消除这个错误?我在 "Rows"

处收到错误

Cust_Form.Designer.cs

namespace DataGridView1
{
    partial class Cust_Form
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <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()
        {
            this.SuspendLayout();
            // 
            // Cust_Form
            // 
            this.ClientSize = new System.Drawing.Size(284, 261);
            this.Name = "Cust_Form";
            this.Load += new System.EventHandler(this.Cust_Form_Load);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.DataGridView dataGridView;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
        private System.Windows.Forms.DataGridViewButtonColumn Column5;
        private System.Windows.Forms.DataGridViewButtonColumn Column4;
    }
}

你的名字 space DataGridView1 在这里制造了歧义。您的控件 ID "dataGridView1" 是否为小写 "d"?

您正在尝试访问 DataGridView1.Rows,但在您的命名空间 DataGridView1 中似乎没有 Rows class.[=17 的声明=] 确保存在这样的实现。

请记住,仅添加命名空间并不总能解决您的错误。