0
사용자 지정 그리기 항목이있는 콤보 상자가 있습니다. 또한 얼룩말 줄무늬를 사용하므로이 때문에 호버 색이 꺼지는 경우가 있습니다. 마우스를 올리면 표시 방법을 제어하려면 어떻게해야합니까?콤보 상자에있는 목록 항목의 호버에 글꼴 색상
여기 내가 사용하는 코드입니다 :
Color zeros = Color.FromArgb(200, 200, 200);
Color ones = Color.FromArgb(225, 225, 255);
private void innerBox_DrawItem(object sender, DrawItemEventArgs e) {
Brush brush = new SolidBrush(e.ForeColor);
Pen pen = new Pen(e.ForeColor);
if (e.Index % 2 == 0) {
Brush backgroundBrush = new SolidBrush(zeros);
e.Graphics.FillRectangle(backgroundBrush, e.Bounds);
} else {
Brush backgroundBrush = new SolidBrush(ones);
e.Graphics.FillRectangle(backgroundBrush, e.Bounds);
}
Tenant tenant = ((ComboBox)sender).Items[e.Index] as Tenant;
Rectangle rect = e.Bounds;
//Draw Tenant Name
if (tenant.TenantName != null) {
e.Graphics.DrawString(tenant.TenantName, e.Font, brush, rect, StringFormat.GenericDefault);
}
rect.X += MaxTenantLength;
e.Graphics.DrawLine(pen, new Point(rect.X - 3, rect.Y), new Point(rect.X - 3, rect.Y + e.Bounds.Height));
//Draw Property
if (tenant.Property != null) {
e.Graphics.DrawString(tenant.Property.PropertyName, e.Font, brush, rect, StringFormat.GenericDefault);
}
rect.X += MaxPropertyLength;
e.Graphics.DrawLine(pen, new Point(rect.X - 3, rect.Y), new Point(rect.X - 3, rect.Y + e.Bounds.Height));
//Draw Rental Unit
if (tenant.RenatlUnit != null) {
e.Graphics.DrawString(tenant.RenatlUnit.UnitNumber, e.Font, brush, rect, StringFormat.GenericDefault);
}
rect.X += MaxRentalUnitLength;
e.DrawFocusRectangle();
}