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; } int orderSign = order == SortOrder.Ascending ? 1 : -1; if (colidx == 0) { this.MS_Sort((a, b) => StringTools.CompIgnoreCase( "" + a.Cells[0].Value, "" + b.Cells[0].Value ) * orderSign ); } else if (colidx == 1) { this.MS_Sort((a, b) => StringTools.Comp( "" + a.Cells[1].Value, "" + b.Cells[1].Value ) * orderSign ); } else // colidx == 2 { this.MS_Sort((a, b) => DoubleTools.Comp( DoubleTools.ToDouble("" + a.Cells[2].Value, 0.0, IntTools.IMAX, 0.0), DoubleTools.ToDouble("" + b.Cells[2].Value, 0.0, IntTools.IMAX, 0.0) ) * orderSign ); } this.MainSheet.Columns[0].HeaderCell.SortGlyphDirection = SortOrder.None; this.MainSheet.Columns[1].HeaderCell.SortGlyphDirection = SortOrder.None; this.MainSheet.Columns[2].HeaderCell.SortGlyphDirection = SortOrder.None; this.MainSheet.Columns[colidx].HeaderCell.SortGlyphDirection = order; }