1

I use Telerik component (RadTreeView) in winforms with Entity Framework 6 . I config it as is:

radTreeView1.DataSource = db.Projects.ToList();

radTreeView1.DisplayMember = "Name1\\Name2";
radTreeView1.ValueMember = "Id1\\Id2";
radTreeView1.ChildMember = "Projects\\ProjectItems";

When I add new record to a table Programmeically, radTreeView1 won't update. even i use this:

db.SaveChanges();
radTreeView1.Update();
radTreeView1.Refresh();

I have change my code to this :

radTreeView1.DataSource = null;
db.SaveChanges();
radTreeView1.DataSource = db.Projects.ToList();

radTreeView1 is updated when i edit a record, or add new record to ProjectItems table. but this error is happen when i add new record to Projects table.

Error:

An unhandled exception of type 'System.Reflection.TargetInvocationException'
occurred in System.dll

Exception:Thrown: "Property accessor 'ProjectItems' on object 'ProjectControl.DAL.Project' threw the following exception:'Object does not match target type.'" (System.Reflection.TargetInvocationException) A System.Reflection.TargetInvocationException was thrown: "Property accessor 'ProjectItems' on object 'ProjectControl.DAL.Project' threw the following exception:'Object does not match target type.'"

can someone help me?

FortyTwo
  • 2,414
  • 3
  • 22
  • 33
  • Can you provide `ProjectControl.DAL.Project` class content including `RadTreeView` configuration? There is a property named `ProjectItems` which throwing reflection exception, in which line actually the exception has thrown? – Tetsuya Yamamoto Nov 16 '17 at 10:08
  • Why app is restarted, Exception isn't happen and new records is display in "RadTreeView" correctly. – M.J. Solaymanpour Nov 16 '17 at 14:36

0 Answers0