问题描述
按这图上的步骤点就会崩溃。不知道怎么调试了。
解决方案
解决方案二:
贴代码吧,应该知道在哪行报错的吧
解决方案三:
在错误代码处打断点,记住是哪步操作出错,然后看当时的各个对象的值,是否超出索引等,然后一步步往上追踪
解决方案四:
附件怎么放上来
解决方案五:
namespaceProject2{partialclassForm1{///<summary>///Requireddesignervariable.///</summary>privateSystem.ComponentModel.IContainercomponents=null;///<summary>///Cleanupanyresourcesbeingused.///</summary>///<paramname="disposing">trueifmanagedresourcesshouldbedisposed;otherwise,false.</param>protectedoverridevoidDispose(booldisposing){if(disposing&&(components!=null)){components.Dispose();}base.Dispose(disposing);}#regionWindowsFormDesignergeneratedcode///<summary>///RequiredmethodforDesignersupport-donotmodify///thecontentsofthismethodwiththecodeeditor.///</summary>privatevoidInitializeComponent(){this.dataGridView_f=newSystem.Windows.Forms.DataGridView();((System.ComponentModel.ISupportInitialize)(this.dataGridView_f)).BeginInit();this.SuspendLayout();////dataGridView_f//this.dataGridView_f.AllowUserToOrderColumns=true;this.dataGridView_f.ColumnHeadersHeightSizeMode=System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;this.dataGridView_f.EditMode=System.Windows.Forms.DataGridViewEditMode.EditOnEnter;this.dataGridView_f.Location=newSystem.Drawing.Point(43,12);this.dataGridView_f.Name="dataGridView_f";this.dataGridView_f.RowTemplate.Height=23;this.dataGridView_f.SelectionMode=System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;this.dataGridView_f.Size=newSystem.Drawing.Size(704,462);this.dataGridView_f.TabIndex=0;this.dataGridView_f.CellEndEdit+=newSystem.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_f_CellEndEdit);////Form1//this.AutoScaleDimensions=newSystem.Drawing.SizeF(6F,12F);this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;this.ClientSize=newSystem.Drawing.Size(903,486);this.Controls.Add(this.dataGridView_f);this.Name="Form1";this.Text="Form1";this.Load+=newSystem.EventHandler(this.Form1_Load);((System.ComponentModel.ISupportInitialize)(this.dataGridView_f)).EndInit();this.ResumeLayout(false);}#endregionprivateSystem.Windows.Forms.DataGridViewdataGridView_f;}}usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespaceProject2{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}[STAThread]staticvoidMain(){//Application.EnableVisualStyles();//Application.SetCompatibleTextRenderingDefault(false);Application.Run(newForm1());}privatevoidForm1_Load(objectsender,EventArgse){DataTabledt=newDataTable();dt.Columns.Add(newDataColumn("dc1"));dt.Columns.Add(newDataColumn("dc2"));dt.Columns.Add(newDataColumn("dc3"));dt.Columns.Add(newDataColumn("Bm"));dt.Columns.Add(newDataColumn("sl"));dt.Columns.Add(newDataColumn("dc6"));dt.Columns.Add(newDataColumn("Ksrq"));dt.Columns.Add(newDataColumn("Jsrq"));for(inti=0;i<1;i++){DataRowdr=dt.NewRow();dr[0]="0"+i;dr[1]="dc1"+i;dr[2]="dc2"+i;dr[3]="1分厂";dr[4]=200.0000;dr[5]=0.0000;dr[6]="2015-10-1100:00:00";dr[7]=i;dt.Rows.Add(dr);}this.dataGridView_f.DataSource=dt;dataGridView_f.Columns["dc1"].ReadOnly=true;dataGridView_f.Columns["dc2"].ReadOnly=true;dataGridView_f.Columns["dc3"].ReadOnly=true;dataGridView_f.Columns["dc6"].ReadOnly=true;}privatevoiddataGridView_f_CellEndEdit(objectsender,DataGridViewCellEventArgse){dataGridView_f.Rows[0].Cells[3].Value="sdfsf";}}}
解决方案六:
dataGridView_f.Rows[0].Cells[3].Value="sdfsf";这句出掉
解决方案七:
我就是想在点的那行的Cell【3】的值改成一个特定值,新增行除外
解决方案八:
引用5楼wyd1520的回复:
dataGridView_f.Rows[0].Cells[3].Value="sdfsf";这句出掉
不去掉不行吗
解决方案九:
你是想点某一行后把那一行的CELL值改掉?if(dataGridView_f.Rows.Count>0){dataGridView_f.Rows[0].Cells[3].Value="sdfsf";这句出掉}