or
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
RadControlsWinFormsApp1
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
setup();
}
public
void
setup()
{
KOMP_G komp_g1 =
new
KOMP_G() { KOMP_G_ID = 1, NAVN =
"Komp1"
, KOMP_UG =
new
List<KOMP_UG>() };
KOMP_G komp_g2 =
new
KOMP_G() { KOMP_G_ID = 2, NAVN =
"Komp2"
, KOMP_UG =
new
List<KOMP_UG>() };
KOMP_UG komp_ug1 =
new
KOMP_UG() { KOMP_UG_ID = 1, NAVN =
"Komp_g1 -> komp_ug1"
, KOMPs =
new
List<KOMP>() };
KOMP_UG komp_ug2 =
new
KOMP_UG() { KOMP_UG_ID = 2, NAVN =
"Komp_g1 -> komp_ug2"
, KOMPs =
new
List<KOMP>() };
KOMP_UG komp_ug3 =
new
KOMP_UG() { KOMP_UG_ID = 3, NAVN =
"Komp_g1 -> komp_ug3"
, KOMPs =
new
List<KOMP>() };
KOMP_UG komp_ug4 =
new
KOMP_UG() { KOMP_UG_ID = 4, NAVN =
"Komp_g1 -> komp_ug4"
, KOMPs =
new
List<KOMP>() };
KOMP komp1 =
new
KOMP() { KOMP_ID = 1, NAVN =
"A"
};
KOMP komp2 =
new
KOMP() { KOMP_ID = 2, NAVN =
"B"
};
KOMP komp3 =
new
KOMP() { KOMP_ID = 3, NAVN =
"C"
};
KOMP komp4 =
new
KOMP() { KOMP_ID = 4, NAVN =
"D"
};
KOMP komp5 =
new
KOMP() { KOMP_ID = 5, NAVN =
"E"
};
KOMP komp6 =
new
KOMP() { KOMP_ID = 6, NAVN =
"F"
};
komp_ug1.KOMPs.Add(komp1);
komp_ug1.KOMPs.Add(komp2);
komp_ug2.KOMPs.Add(komp3);
komp_ug3.KOMPs.Add(komp4);
komp_ug4.KOMPs.Add(komp5);
komp_ug4.KOMPs.Add(komp6);
komp_g1.KOMP_UG.Add(komp_ug1);
komp_g1.KOMP_UG.Add(komp_ug2);
komp_g2.KOMP_UG.Add(komp_ug3);
komp_g2.KOMP_UG.Add(komp_ug4);
List<IKomp> komps =
new
List<IKomp>();
komps.Add(komp_g1);
komps.Add(komp_g2);
//SETUP TreeView
radTreeView1.DataSource = komps;
radTreeView1.DisplayMember =
"Description"
;
radTreeView1.ValueMember =
"Value"
;
radTreeView1.ParentMember =
"Parent"
;
radTreeView1.ChildMember =
"Children"
;
}
}
public
interface
IKomp
{
string
Value {
get
; }
string
Description {
get
; }
IKomp Parent {
get
; }
IEnumerable<IKomp> Children {
get
; }
}
public
class
KOMP : IKomp
{
public
int
KOMP_ID;
public
string
NAVN;
public
KOMP_UG KOMP_UG;
#region IKomp Members
public
string
Value
{
get
{
return
this
.KOMP_ID.ToString(); }
}
public
string
Description
{
get
{
return
this
.NAVN; }
}
public
IKomp Parent
{
get
{
return
this
.KOMP_UG; }
}
public
IEnumerable<IKomp> Children
{
get
{
return
null
; }
}
#endregion
}
public
class
KOMP_G : IKomp
{
public
int
KOMP_G_ID;
public
string
NAVN;
public
List<KOMP_UG> KOMP_UG;
#region IKomp Members
public
string
Value
{
get
{
return
this
.KOMP_G_ID.ToString(); }
}
public
string
Description
{
get
{
return
this
.NAVN; }
}
public
IKomp Parent
{
get
{
return
null
; }
}
public
IEnumerable<IKomp> Children
{
get
{
return
this
.KOMP_UG.Cast<IKomp>(); }
}
#endregion
}
public
class
KOMP_UG : IKomp
{
public
int
KOMP_UG_ID;
public
string
NAVN;
public
KOMP_G KOMP_G;
public
List<KOMP> KOMPs;
#region IKomp Members
public
string
Value
{
get
{
return
this
.KOMP_UG_ID.ToString(); }
}
public
string
Description
{
get
{
return
this
.NAVN; }
}
public
IKomp Parent
{
get
{
return
this
.KOMP_G; }
}
public
IEnumerable<IKomp> Children
{
get
{
return
this
.KOMPs.Cast<IKomp>(); }
}
#endregion
}
}