private void Toggle(int index)
{
if (index < this.layout.Items.Count)
{
PanelBase item = this.layout.Items[index] as PanelBase;
IComponentChangeService changeService =
(IComponentChangeService)GetService(typeof(IComponentChangeService));
try
{
changeService.OnComponentChanging(this.layout,
TypeDescriptor.GetProperties(this.layout)["Items"]);
if (item.Collapsed)
{
this.ExpandItem(item);
}
else
{
TypeDescriptor.GetProperties(item)["Collapsed"].SetValue(item, true);
item.Collapsed = true;
}
}
finally
{
changeService.OnComponentChanged(this.layout,
TypeDescriptor.GetProperties(this.layout)["Items"],
null, null);
}
}
}