回复 1楼根2的帖子
可以通过以下代码获取,具体思路是先获取 DataView 再通过当前列的排序状态对 DataView 进行排序转换为 DataTable:
- private void Form1_Load(object sender, EventArgs e)
- {
- DataTable dt = new DataTable("Testing");
- dt.Columns.Add("Number");
- dt.Columns.Add("Letter");
- dt.Rows.Add(new Object[] { "1", "One" });
- dt.Rows.Add(new Object[] { "2", "Two" });
- FarPoint.Win.Spread.Model.DefaultSheetDataModel dataModel = new FarPoint.Win.Spread.Model.DefaultSheetDataModel(dt);
- fpSpread1.ActiveSheet.Models.Data = dataModel;
- fpSpread1.Sheets[0].Columns[0].AllowAutoSort = true;
- }
- private void ddToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (this.fpSpread1.ActiveSheet.GetColumnSortIndicator(0)== SortIndicator.Descending)
- {
- var data = this.fpSpread1.ActiveSheet.GetDataView(false);
- data.Sort = "Number DESC";
- DataTable dt = data.ToTable();
- }
- }
复制代码 |