Ejemplo n.º 1
0
        /// <summary>
        /// Overrides parent OnDrawItem method to perform custom painting
        /// </summary>
        /// <param name="pe"></param>
        protected override void OnDrawItem(DrawItemEventArgs pe)
        {
            pe.DrawBackground();
            pe.DrawFocusRectangle();
            Rectangle bounds = pe.Bounds;

            // Check whether the index is valid
            if (pe.Index >= 0 && pe.Index < base.Items.Count)
            {
                ImageListBoxItem item = (ImageListBoxItem)base.Items[pe.Index];
                int iOffset           = 0;
                // If the image list is present and the image index is set, draw the image
                if (imageList != null)
                {
                    if (item.ImageIndex != -1 && item.ImageIndex < imageList.Images.Count)
                    {
                        imageList.Draw(pe.Graphics, bounds.Left, bounds.Top, item.ImageIndex);
                    }
                    iOffset += imageList.ImageSize.Width;
                }
                // Draw item text
                pe.Graphics.DrawString(item.Text, pe.Font, new SolidBrush(pe.ForeColor),
                                       bounds.Left + iOffset, bounds.Top);
            }
            base.OnDrawItem(pe);
        }
Ejemplo n.º 2
0
 private int DoInsertItem(int index, ImageListBoxItem item)
 {
     item.imageList = imageList;
     item.itemIndex = index;
     base.Items.Insert(index, item);
     return(index);
 }
Ejemplo n.º 3
0
 private void DoSetElement(int index, ImageListBoxItem value)
 {
     base.Items[index] = value;
 }
Ejemplo n.º 4
0
 public int Add(ImageListBoxItem item)
 {
     return(owner.DoInsertItem(Count, item));
 }
Ejemplo n.º 5
0
 public void Insert(int index, ImageListBoxItem item)
 {
     owner.DoInsertItem(index, item);
 }
Ejemplo n.º 6
0
 public void Remove(ImageListBoxItem item)
 {
     throw new NotSupportedException();
 }