BindingList<ComboData> _comboItems = new BindingList<ComboData>(); // ComboBox의 DataSource 적용된것
private void Combo_DrawItem(object sender, DrawItemEventArgs e)
{
Brush brush = null;
ComboBox combo = (ComboBox)sender;
if (combo == null || _comboItems == null)
{
return;
}
if (대상인 색깔..)
{
//백그라운드 색
e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
//글자 색
brush = ((e.State & DrawItemState.Selected) > 0) ? SystemBrushes.HotTrack : SystemBrushes.ControlText;
e.Graphics.DrawString(_comboItems[e.Index].Text, combo.Font, brush, e.Bounds);
}
else
{
e.DrawBackground();
//백그라운드 색
e.Graphics.FillRectangle(Brushes.DarkGray, e.Bounds);
//글자 색
brush = ((e.State & DrawItemState.Selected) > 0) ? SystemBrushes.HighlightText : SystemBrushes.ControlText;
e.Graphics.DrawString(_comboItems[e.Index].Text, combo.Font, brush, e.Bounds);
e.DrawFocusRectangle();
}
}
'c# > WinForm' 카테고리의 다른 글
WinForm) Transfer Data From Form to Form ( 폼과 폼간에 데이터를 전송하는 소스) (0) | 2018.09.19 |
---|---|
WinForm HorizontalScroll False 하는 방법..스크롤 이슈 (0) | 2018.09.18 |
TableLayoutPanel 마우스 스크롤 (0) | 2018.09.07 |
TableLayoutPanel SLOW 에서 FAST 하게 하는 코드 (0) | 2018.09.07 |
WinForm Tab내에 새로운 Form 띄우기 (0) | 2018.09.06 |