+2  A: 

It looks like you need to assign _grouppedResto to an anonymous type as in:

var yourSequence = _groupedResto.Select((value, index) => new { index = index, value = value });
dgvHeader.DataSource = yourSequence;

I'd be happy to help with any particulars you care to provide. Good luck, hope this helped :)

mkelley33
Thanks for your share your thoughts, btw the datagrid autogeneratecolumns property is set to false, so the datagrid could not generate the columns.
Angel Escobedo
Yeah, no problem. Its always the tiny annoyances that tend to trip me up. Glad to hear you found the problem.
mkelley33
A: 

To combine the index with the properties of your list element you need to change your select statement into something like this:

_grouppedResto.Select(
  (value, index) => new {
    index = index, propertyA = value.propertyA, propertyB = value.propertyB
  }
);
Martin Liversage
Well I think if you make it that way yo need to specify the <T> object after the keyword "new" cause propertyes won't show up...
Angel Escobedo
A: 

Well, I use this way to solve this... (I think is the worst way, cause you have to modified the domain class)

public class RGVCAFAC
    {
        public int index { get; set; }
        public string CODEAUX { get; set; }

        public string FECRGV { get; set; }
        public string TDORGV { get; set; }
        public string MONRGV { get; set; }
        public string NDORGV { get; set; }
        public string RUCCLI { get; set; }
        public string RAZCLI { get; set; }
        public string CDCRGV { get; set; }
        public string TERRGV { get; set; }
        public string PDSRGV { get; set; }
        public double VVTRGVS { get; set; }
        public double IGVRGVS { get; set; }
        public double TOTRGVS { get; set; }
        public string TCARGV { get; set; }
        public double VVTRGVD { get; set; }
        public double IGVRGVD { get; set; }
        public double TOTRGVD { get; set; }
        public string PACEST { get; set; }

        public string CODUNI { get; set; }

        public string DIRCLI { get; set; }
        public string TELCLI { get; set; }
        public int PFLAG { get; set; }


        //I have to add the following, so generators are useless :(


        public RGVCAFAC()
        {
        }

        public RGVCAFAC(RGVCAFAC x)
        {
            this.CODEAUX = x.CODEAUX;
            this.FECRGV = x.FECRGV;
            this.TDORGV = x.TDORGV;
            this.MONRGV = x.MONRGV;
            this.RUCCLI = x.RUCCLI;
            this.RAZCLI = x.RAZCLI;
            this.CDCRGV = x.CDCRGV;
            this.TERRGV = x.TERRGV;
            this.PDSRGV = x.PDSRGV;
            this.VVTRGVS = x.VVTRGVS;
            this.IGVRGVS = x.IGVRGVS;
            this.TOTRGVS = x.TOTRGVS;
            this.TCARGV = x.TCARGV;
            this.VVTRGVD = x.VVTRGVD;
            this.IGVRGVD = x.IGVRGVD;
            this.TOTRGVD = x.TOTRGVD;
            this.PACEST = x.PACEST;
            this.CODUNI = x.CODUNI;
            this.DIRCLI = x.DIRCLI;
            this.TELCLI = x.TELCLI;
            this.PFLAG = x.PFLAG;
        }
    }

and finally :

var yourSequence = _grouppedResto.
                    Select((value, index) => new RGVCAFAC(value) { index = index+1, rgvcafac = value }).ToList(); //need to begin on 1 not on 0
                dgvCabecera.DataSource = yourSequence;
Angel Escobedo
If someone find another way, please dont doubt to post it, I could mark it as an answer, for other people with the same cue
Angel Escobedo
A: 
int theIndex = 1;

foreach(var x in _grouppedResto)
{
  x.index = theIndex;
  theIndex += 1;
}
David B
Thanks for responses, Im already using that snippet, but Im looking for a LINQ solution.
Angel Escobedo