用Spread实现拖拽自增填充单元格
打开this.fpSpread1.AllowDragFill = true;
可以拖拽复制单元格的值。
在如下事件中进行自增处理
this.fpSpread1.DragFillBlockCompleted += fpSpread1_DragFillBlockCompleted;
示意代码如下:
void fpSpread1_DragFillBlockCompleted(object sender, FarPoint.Win.Spread.DragFillBlockCompletedEventArgs e)
{
if (e.Direction == FillDirection.Down
|| e.Direction == FillDirection.Up)
{
for (int i = e.RowBegin + 1; i < e.RowBegin + 1 + e.NumberToCopy; i++)
{
this.fpSpread1.ActiveSheet.Cells.Value = Convert.ToInt64(this.fpSpread1.ActiveSheet.Cells.Value) + i;
}
}
}
Demo如下:
页:
[1]