I'm on a project where base control is a DatagridView, in there is displaying numbers of production quantities, whish every row is a bach on the production process and every column is a type of product in the bash.
Every Bash has a time to acomplish to finalize the process, when time is ended, the cell in the row must be colored, then the user has the ability to add more time if needed to every single product.
So my proposal was adding to every Cell object two properties
- State of the bash product (int).
- Extended time in minutes (int 0 default).
So I create my own DataGridViewCell this way
public class PedidosCell : DataGridViewCell
{
private int _estado;
private int _tiempo;
public int Estado
{
get { return _estado; }
set { _estado = value; }
}
public int TiempoExtra
{
get { return _tiempo; }
set { _tiempo = value; }
}
}
After that I created the colum that uses PedidosCell
public class PedidosColumn : DataGridViewColumn
{
public PedidosColumn()
: base(new PedidosCell())
{
}
public override DataGridViewCell CellTemplate
{
get
{
return base.CellTemplate;
}
set
{
// Ensure that the cell used for the template is a PedidosCell.
if (value != null &&
!value.GetType().IsAssignableFrom(typeof(PedidosCell)))
{
throw new InvalidCastException("Must be a PedidosCell");
}
base.CellTemplate = value;
}
}
The problem starts here because if i call a constructor
PedidosColumn col = new PedidosColumn();
the propertie
col.CellTemplate.TiempoExtra
doesn't exist; AND it's obvious because the overrider CellTemplate is returning the original CellTemplate
But how can i do it (if possible) to make a simple dgView.Row[0].Cell[2].TiempoExtra
or dgView.Row[0].Cell[2].Estado
to get the information I need to know how the cell will be colorated?
Thank's For the help
Aucun commentaire:
Enregistrer un commentaire