【问题标题】:c# BindingList read-only errorc# BindingList 只读错误
【发布时间】:2012-04-15 15:55:44
【问题描述】:

我一直在寻找问题的可能原因,但似乎找不到:

错误:

System.NotSupportedException:集合是只读的。在 System.ThrowHelper.ThrowNotSupportedException(异常资源 资源)在 System.Collections.ObjectModel.Collection`1.Add(T 项目)在 WindowsFormsApplication1.Form1.Btn_CSVSEATINGPLAN_Click(对象发件人, C:\Users\aRJiJon\Documents\Visual Studio 中的 EventArgs e) 2010\Projects\WindowsFormsApplication_1\WindowsFormsApplication1\Form1.cs:line 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()
{
}

谁能告诉我我错过了什么?

【问题讨论】:

  • 哦,顺便说一句,第 72 行是:CSV_Seating_Plan.Add(new csv_SeatingPlan());

标签: c# visual-studio-2010 bindinglist


【解决方案1】:

这意味着您的通用集合类的 IList 的底层实现正在为 IsReadOnly 属性返回 true。

【讨论】:

  • 啊找到了解决方法:而不是 CSV_Seating_Plan = new BindingList(container);我刚刚有: CSV_Seating_Plan = new BindingList(){ foreach (row in container){ add new element on csv_steaingplan }
猜你喜欢
  • 2013-05-17
  • 1970-01-01
  • 2013-05-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-14
  • 1970-01-01
相关资源
最近更新 更多