using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace ControlesJey
{
class MiListView:ListView
{
public MiListView()
{
this.View = View.Details;
this.GridLines = true;
this.FullRowSelect = true;
this.HideSelection = false;
}
int colp=-1;
public int IndiceColumnaPrimaria
{
get{return colp;}
set{colp=value;}
}
Color c1=Color.White;
public Color ColorFilasImpares
{
get { return c1; }
set { c1 = value; }
}
Color c2=Color.Gainsboro;
public Color ColorFilasPares
{
get { return c2; }
set { c2 = value; }
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
if ((this.Columns.Count > 0)&&(colp!=-1))
{
int anchoCol=0;
for (int i = 0; i <= this.Columns.Count - 1; i++)
{
if (i != colp)
{
anchoCol += this.Columns[i].Width;
}
}
anchoCol = (this.Width - anchoCol) - 22;
this.Columns[colp].Width = anchoCol;
}
}
public void Colorear()
{
int cont = 1;
foreach (ListViewItem it in this.Items)
{
if (cont % 2 == 0)
{
it.BackColor = c2;
}
else
{
it.BackColor = c1;
}
cont++;
}
}
}
}