标题:斑竹帮看看,怎么解决?
只看楼主
huchengang
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2010-10-23
结帖率:25%
已结贴  问题点数:10 回复次数:4 
斑竹帮看看,怎么解决?
namespace Sample_22
{
    partial class DGVForm
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.dgvData = new System.Windows.Forms.DataGridView();
            this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Name = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Email = new System.Windows.Forms.DataGridViewTextBoxColumn();
            (()(this.dgvData)).BeginInit();
            this.SuspendLayout();
            //
            // dgvData
            //
            this.dgvData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dgvData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.ID,
            this.Name,
            this.Email});
            this.dgvData.Location = new System.Drawing.Point(2, 0);
            this.dgvData.Name = "dgvData";
            this.dgvData.RowTemplate.Height = 23;
            this.dgvData.Size = new System.Drawing.Size(434, 272);
            this.dgvData.TabIndex = 0;
            this.dgvData.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvData_CellContentClick);
            //
            // ID
            //
            this.ID.HeaderText = "ID";
            this.ID.Name = "ID";
            //
            // Name
            //
            this.Name.HeaderText = "Name";
            this.Name.Name = "Name";
            //
            // Email
            //
            this.Email.HeaderText = "Email";
            this.Email.Name = "Email";
            //
            // DGVForm
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(520, 301);
            this.Controls.Add(this.dgvData);
            this.Name = "DGVForm";
            this.Text = "数据网格视图控件";
            this.Load += new System.EventHandler(this.DGVForm_Load);
            (()(this.dgvData)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.DataGridView dgvData;
        private System.Windows.Forms.DataGridViewTextBoxColumn ID;
        private System.Windows.Forms.DataGridViewTextBoxColumn Name;
        private System.Windows.Forms.DataGridViewTextBoxColumn Email;
    }
错误有两处:
警告    1    “Sample_22.DGVForm.Name”隐藏了继承的成员“System.Windows.Forms.Control.Name”。如果是有意隐藏,请使用关键字 new。  
错误    2    无法将类型“string”隐式转换为“System.Windows.Forms.DataGridViewTextBoxColumn”   
搜索更多相关主题的帖子: 斑竹 
2010-11-17 21:19
南川
Rank: 4
等 级:业余侠客
威 望:1
帖 子:111
专家分:235
注 册:2010-6-25
得分:10 
this.Name = new System.Windows.Forms.DataGridViewTextBoxColumn();
这句话有问题,this.Name这里指的是窗体的Name属性,而你这句的目的是在这个窗体里实例化一个DataGridViewTextBoxColumn对象,而它的名字是Name。造成了语法的混淆。所以,解决的方法就是你把控件的名字改下,不要叫Name了。如果希望表头有Name,只需要保持HeaderText="Name"就OK了。
2010-11-17 21:42
c1_wangyf
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:7
帖 子:665
专家分:2832
注 册:2010-5-24
得分:0 
楼上说的对!!
2010-11-17 21:50
huchengang
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2010-10-23
得分:0 
谢谢2楼的指点,真的是你说的那样,控件name重了,已经解决了。
2010-11-17 22:09
南川
Rank: 4
等 级:业余侠客
威 望:1
帖 子:111
专家分:235
注 册:2010-6-25
得分:0 
回复 4楼 huchengang
崩忘记结贴
2010-11-17 22:28



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-326067-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.087333 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved