protected virtual void InitializeStateImageList()
{
if (this.DesignMode)
return;
if (this.StateImageList == null) {
this.StateImageList = new ImageList();
this.StateImageList.ImageSize = new Size(16, 16);
this.StateImageList.ColorDepth = ColorDepth.Depth32Bit;
}
if (this.RowHeight != -1 &&
this.View == View.Details &&
this.StateImageList.ImageSize.Height != this.RowHeight) {
this.StateImageList = new ImageList();
this.StateImageList.ImageSize = new Size(16, this.RowHeight);
this.StateImageList.ColorDepth = ColorDepth.Depth32Bit;
}
if (!this.CheckBoxes)
return;
// The internal logic of ListView cycles through the state images when the primary
// checkbox is clicked. So we have to get exactly the right number of images in the
// image list.
if (this.StateImageList.Images.Count == 0)
this.AddCheckStateBitmap(this.StateImageList, UNCHECKED_KEY, CheckBoxState.UncheckedNormal);
if (this.StateImageList.Images.Count <= 1)
this.AddCheckStateBitmap(this.StateImageList, CHECKED_KEY, CheckBoxState.CheckedNormal);
if (this.TriStateCheckBoxes && this.StateImageList.Images.Count <= 2)
this.AddCheckStateBitmap(this.StateImageList, INDETERMINATE_KEY, CheckBoxState.MixedNormal);
else {
if (this.StateImageList.Images.ContainsKey(INDETERMINATE_KEY))
this.StateImageList.Images.RemoveByKey(INDETERMINATE_KEY);
}
}