你好,可以通过 SetTag() 方法在排序前设置第二行单元格 Tag,然后在 fpSpread1_AutoSortedColumn 事件中设置该 Tag 所在行为 ActiveRow,具体代码如下:
- private void Form1_Load(object sender, EventArgs e)
- {
- fpSpread1.ActiveSheet.SetTag(1, 0, "AppTag");
- this.fpSpread1.ActiveSheet.Columns[0].AllowAutoSort = true;
- }
- private void fpSpread1_AutoSortedColumn(object sender, FarPoint.Win.Spread.AutoSortedColumnEventArgs e)
- {
- for (int i = 0; i < fpSpread1_Sheet1.RowCount; i++)
- {
- if (this.fpSpread1_Sheet1.GetTag(i, 0) != null)
- {
- this.fpSpread1_Sheet1.SetActiveCell(i, 0);
- }
- }
- }
复制代码 |