1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace test_listView
{
public partial class Form1 : Form
{
static public int count = 10;
public Form1()
{
InitializeComponent();
}
private void Draw_Sub_Item(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex == 1)
{
int width = (10 - count)*(e.Bounds.Width/10);
e.Graphics.FillRectangle(Brushes.Red,e.Bounds.X, e.Bounds.Y, width, e.Bounds.Height);
e.Graphics.DrawString(Convert.ToString((10 - count)) + " secondes", listView1.Font, Brushes.Black, e.Bounds);
e.DrawFocusRectangle(e.Bounds);
}
else
{
e.DrawText();
}
}
private void Draw_Item(object sender, DrawListViewItemEventArgs e)
{
Graphics dc = listView1.CreateGraphics();
dc.FillRectangle(Brushes.Blue, e.Bounds);
e.DrawFocusRectangle();
}
private void Draw_Header(object sender, DrawListViewColumnHeaderEventArgs e)
{
e.DrawBackground();
e.DrawText();
return;
}
private void timer_tick(object sender, EventArgs e)
{
if (count > 0)
{
count--;
}
else
{
count = 10;
}
listView1.Refresh();
}
}
} |
Partager