or
The problem I am running into is that the selection seems to be cleared as soon as the check box is clicked. Can you suggest a solution that would accomplish this behavior?
class
Company : INotifyPropertyChanged
{
private
string
_code;
private
readonly
BindingList<Project> _projects;
public
Company(
string
companyCode):
this
(companyCode,
null
){}
public
Company(
string
companyCode, IList<Project> projects)
{
_code = companyCode;
_projects = projects ==
null
?
new
BindingList<Project>() :
new
BindingList<Project>(projects);
}
public
String Code
{
get
{
return
_code; }
set
{
_code = value;
OnPropertyChanged(
"Code"
);
}
}
public
BindingList<Project> Projects
{
get
{
return
_projects; }
}
public
event
PropertyChangedEventHandler PropertyChanged;
// Create the OnPropertyChanged method to raise the event
protected
void
OnPropertyChanged(
string
name)
{
var handler = PropertyChanged;
if
(handler !=
null
)
{
handler(
this
,
new
PropertyChangedEventArgs(name));
}
}
}
class
Project : INotifyPropertyChanged
{
private
string
_code;
private
readonly
BindingList<Phase> _phases;
public
Project(
string
projectCode) :
this
(projectCode,
null
) { }
public
Project(
string
projectCode, IList<Phase> phases)
{
_code = projectCode;
_phases = phases ==
null
?
new
BindingList<Phase>() :
new
BindingList<Phase>(phases);
}
public
String Code
{
get
{
return
_code; }
set
{
_code = value;
OnPropertyChanged(
"Code"
);
}
}
public
BindingList<Phase> Phases
{
get
{
return
_phases; }
}
public
event
PropertyChangedEventHandler PropertyChanged;
// Create the OnPropertyChanged method to raise the event
protected
void
OnPropertyChanged(
string
name)
{
var handler = PropertyChanged;
if
(handler !=
null
)
{
handler(
this
,
new
PropertyChangedEventArgs(name));
}
}
}
_companiesTreeView.DataSource = _dataSource;
_companiesTreeView.DisplayMember =
"Code\\Code\\Code"
;
_companiesTreeView.ChildMember =
"Companies\\Projects\\Phases"
;
_companiesTreeView.ValueMember =
"Code\\Code\\Code"
;