SourceGrid.RangeRegion.GetRowsIndex C# (CSharp) Method

GetRowsIndex() public method

Returns all the selected rows index
public GetRowsIndex ( ) : int[]
return int[]
        public virtual int[] GetRowsIndex()
        {
            System.Collections.ArrayList indexList = new System.Collections.ArrayList();
            RangeCollection ranges = GetRanges();
            for (int iRange = 0; iRange < ranges.Count; iRange++)
            {
                for (int r = ranges[iRange].Start.Row; r <= ranges[iRange].End.Row; r++)
                {
                    if (indexList.Contains(r) == false)
                        indexList.Add(r);
                }
            }
            int[] ret = new int[indexList.Count];
            indexList.CopyTo(ret, 0);

            return ret;
        }

Usage Example

Exemplo n.º 1
0
		public void GetRowsIndex()
		{
			RangeRegion region = new RangeRegion();
			region.Add(new Range(0, 0, 0, 0));
			region.Add(new Range(2, 2, 2, 2));
			
			int[] indexes = region.GetRowsIndex();
			Assert.AreEqual(2, indexes.Length);
			Assert.AreEqual(0, indexes[0]);
			Assert.AreEqual(2, indexes[1]);
		}