简体   繁体   English

c#BindingList只读错误

[英]c# BindingList read-only error

I keep trying to look for the possible cause of the problem but I cant seem to find it: 我一直在努力寻找问题的可能原因,但我似乎无法找到它:

Error: 错误:

System.NotSupportedException: Collection is read-only. System.NotSupportedException:Collection是只读的。 at System.ThrowHelper.ThrowNotSupportedException(ExceptionResource resource) at System.Collections.ObjectModel.Collection`1.Add(T item) at WindowsFormsApplication1.Form1.Btn_CSVSEATINGPLAN_Click(Object sender, EventArgs e) in C:\\Users\\aRJiJon\\Documents\\Visual Studio 2010\\Projects\\WindowsFormsApplication_1\\WindowsFormsApplication1\\Form1.cs:line 72 System.ThrowHelper.ThrowNotSupportedException(ExceptionResource资源)位于C:\\ Users \\ aRJiJon \\ Documents \\ Visual中WindowsFormsApplication1.Form1.Btn_CSVSEATINGPLAN_Click(Object sender,EventArgs e)的System.Collections.ObjectModel.Collection`1.Add(T item) Studio 2010 \\ Projects \\ WindowsFormsApplication_1 \\ WindowsFormsApplication1 \\ Form1.cs:第72行

            this.dataGridView1.DefaultCellStyle.Font = new Font("Tahoma", 11);
            bindingCSVSP.DataSource = CSV_Seating_Plan;
            bindingCSVSP.AllowNew = true;

CSV_Seating_Plan.AllowNew = true;
CSV_Seating_Plan.AllowRemove = true;
CSV_Seating_Plan.RaiseListChangedEvents = true;
CSV_Seating_Plan.AllowEdit = true;
this.dataGridView1.DataSource = bindingCSVSP;
this.btn_Process_SP.Enabled = true;
CSV_Seating_Plan.Add(new csv_SeatingPlan());

public string examperiod;
[FieldConverter(ConverterKind.Date, "dd/mm/yyyy")]
public DateTime date_Exam;
public string time;
public string exam_Code;
public string id_Student;
public string name_Student;
public string candidatenum_Student;
public string seat_num;
public string _WSS_EXEC;
public string exam_loc;


#region getsetmethods.
public string EXAMPERIOD
{ get { return this.examperiod; } }
public DateTime DATE_TIME
{ get { return this.date_Exam; } }
public string TIME
{ get { return this.time; } }
public string EXAM_CODE
{ get { return this.exam_Code; } }
public string ID_STUDENT
{ get { return this.id_Student; } }
public string NAME_STUDENT
{ get { return this.name_Student; } }
public string CANDIDATE_NUMBER
{ get { return this.candidatenum_Student; } }
public string SEAT_NUM
{ get { return this.seat_num; } }
public string WSS_EXEC
{ get { return this._WSS_EXEC; } }
public string EXAM_LOC
{ get { return this.exam_loc; } }
#endregion

public csv_SeatingPlan()
{
}

Can anyone tell me what I'm missing? 谁能告诉我我错过了什么?

这意味着IList for the generic collection class的底层实现对于IsReadOnly属性返回true。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM