c# BindingList 只读错误

标签 c# visual-studio-2010 bindinglist

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

错误:

System.NotSupportedException: Collection is read-only. 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

            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()
{
}

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

最佳答案

这意味着 IList 的基础实现为您的通用集合类返回 true 的 IsReadOnly 属性。

关于c# BindingList 只读错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9968811/

相关文章:

.net - 使用 WPF 的网格中的按钮数组

c# - WPF将项目添加到BindingList不会更新Viewmodel中的另一个属性

.net - DataGridView 排序和例如.NET 中的 BindingList<T>

C# float.ToString 舍入值

c++ - CMake 不会为简单的测试程序生成 vc pdb

visual-studio-2010 - 抑制代码分析应用程序错误

c# - 如何为 PropertyDescriptor 定义类级属性以对 BindingList 进行排序?

c# - 如何按 2 列比较两个 csv 文件?

c# - 如果我没有 UI,是否应该使用 BackgroundWorker 类来处理任务队列?

c# - Windows Service通信,套接字,C#