본문 바로가기
프로그래밍

[C#] CheckedListBox Check된것만 Color 변경

by 건우아빠유리남편 2011. 3. 16.
반응형
    public partial class ColorCheckedListBox : CheckedListBox
    {
        public ColorCheckedListBox()
        {
            InitializeComponent();
            for (int i = 0; i < 7; i++)
                this.Items.Add(i + "번째 아이템");
        }
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            DrawItemEventArgs e2 =
                new DrawItemEventArgs(
                e.Graphics, e.Font, new Rectangle(e.Bounds.Location, e.Bounds.Size),
                e.Index, e.State, e.ForeColor,
                this.CheckedIndices.Contains(e.Index) ? Color.Red : SystemColors.Window);
           
            base.OnDrawItem(e2);
        }
    }




아 찾기 심들다.

반응형

댓글