コード例 #1
0
        public CellRange(System.Windows.Forms.DataGridViewSelectedCellCollection sel)
        {
            // assume invalid range
            r1 = r2 = c1 = c2 = -1;

            // build CellRange using the first and last cells in the
            // DataGridViewSelectedCellCollection
            if (sel.Count > 0)
            {
                var cell1 = sel[0];
                var cell2 = sel[sel.Count - 1];
                r1 = cell1.RowIndex;
                c1 = cell1.ColumnIndex;
                r2 = cell2.RowIndex;
                c2 = cell2.ColumnIndex;
            }
        }
コード例 #2
0
ファイル: Extensions.cs プロジェクト: Kn1fe/DataTranslator
 public static System.Collections.ArrayList SetIndexesColumns(System.Windows.Forms.DataGridViewSelectedCellCollection SelectedCells)
 {
     System.Collections.ArrayList result = new System.Collections.ArrayList();
     for (int i = 0; i < SelectedCells.Count; i++)
     {
         bool check = true;
         for (int k = 0; k < result.Count; k++)
         {
             if ((int)result[k] == SelectedCells[i].ColumnIndex)
             {
                 check = false;
                 break;
             }
         }
         if (check)
         {
             result.Add(SelectedCells[i].ColumnIndex);
         }
     }
     result.Sort();
     return(result);
 }