using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ItemColorC
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
listBox1.DrawMode = DrawMode.OwnerDrawFixed;
listBox1.DrawItem += listBox1_DrawItem;
}
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
Graphics g = e.Graphics;
Color color = Color.blue;
for (int i = 0; i < listBox1.Items.Count; i++)
{
g.DrawString("ListBoxItem", e.Font, new SolidBrush(color), new PointF(e.Bounds.X, e.Bounds.Y));
}
e.DrawFocusRectangle();
}
}
}
No comments:
Post a Comment