2012-04-01 14 views
5

मैं समस्या के संभावित कारण देखने के लिए कोशिश कर रखना, लेकिन मैं नहीं कर सकते इसे खोजने लगते हैं:C# 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() 
{ 
} 

किसी को भी मुझे बता सकते हैं क्या मुझे याद आ रही है?

+0

ओएच बीटीडब्ल्यू, लाइन 72 है: CSV_Seating_Plan.Add (नया csv_SeatingPlan()); – Magikarp

उत्तर

4

इसका मतलब है कि आपके लिए सामान्य संग्रह वर्ग के लिए आईएलआईस्ट के अंतर्निहित कार्यान्वयन IsReadOnly संपत्ति के लिए सच हो रहा है।

+3

आह को फिक्स्ड मिला: CSV_Seating_Plan = new BindingList (कंटेनर) के बजाय; मेरे पास अभी था: CSV_Seating_Plan = नया बाइंडिंगलिस्ट () { foreach (कंटेनर में पंक्ति) { csv_steaingplan } पर नया तत्व जोड़ें – Magikarp

संबंधित मुद्दे