Esempio n. 1
0
        private void MS_Sort(int colidx)
        {
            SortOrder order = this.MainSheet.Columns[colidx].HeaderCell.SortGlyphDirection;

            if (order == SortOrder.Ascending)
            {
                order = SortOrder.Descending;
            }
            else
            {
                order = SortOrder.Ascending;
            }

            if (colidx == 8)             // 数値カラム
            {
                this.MS_Sort((a, b) => IntTools.Comp(
                                 int.Parse("" + a.Cells[colidx].Value),
                                 int.Parse("" + b.Cells[colidx].Value)
                                 ) * (order == SortOrder.Ascending ? 1 : -1));
            }
            else             // その他 ⇒ 文字列カラム
            {
                this.MS_Sort((a, b) => StringTools.CompIgnoreCase(
                                 "" + a.Cells[colidx].Value,
                                 "" + b.Cells[colidx].Value
                                 ) * (order == SortOrder.Ascending ? 1 : -1));
            }

            for (int ci = 0; ci < this.MainSheet.ColumnCount; ci++)
            {
                this.MainSheet.Columns[ci].HeaderCell.SortGlyphDirection = SortOrder.None;
            }
            this.MainSheet.Columns[colidx].HeaderCell.SortGlyphDirection = order;
        }