CellType
this.FpSpread1.ActiveSheetView.Columns[0].CellType = new FarPoint.Web.Spread.CheckBoxCellType(); 复制代码2、重写“删除”按钮的默认行为(服务端)
protected override void Render(HtmlTextWriter writer) { WebControl delButton = FpSpread1.FindControl("Delete") as WebControl; if (delButton != null) { delButton.Attributes.Add("onclick", "MultiDlete();return false;"); } base.Render(writer); } 复制代码3、重写“删除”按钮的默认行为(客服端)
-
<script language="javascript" type="text/javascript"> function MultiDlete() { var ss = FpSpread("FpSpread1"); if (ss != null) { ss.UpdatePostbackData(); ss.CallBack("MultiDlete"); } } </script> 复制代码
4、删除用户选择的数据行
-
protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e) { if (e.CommandName.Equals("MultiDlete")) { for (int r = FpSpread1.ActiveSheetView.RowCount - 1; r >= 0; r--) { var check = FpSpread1.ActiveSheetView.Cells[r, 0].Value; if (check != null && (Convert.ToInt32(check) == 1)) { FpSpread1.ActiveSheetView.Rows.Remove(r, 1); } } } } 复制代码
第二种:删除用户选中的所有行
1、重写“删除”按钮的默认行为(服务端)
-
protected override void Render(HtmlTextWriter writer) { WebControl delButton = FpSpread1.FindControl("Delete") as WebControl; if (delButton != null) { delButton.Attributes.Add("onclick", "MultiDlete();return false;"); } base.Render(writer); } 复制代码
2、重写“删除”按钮的默认行为(客服端)
-
<script language="javascript" type="text/javascript"> function MultiDlete() { var ss = FpSpread("FpSpread1"); if (ss != null) { ss.UpdatePostbackData(); ss.CallBack("MultiDlete"); ss.ClearSelection(); } } </script> 复制代码
3、删除用户选择的数据行
protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e) { if (e.CommandName.Equals("MultiDlete")) { CellRange[] cRanges = FpSpread1.ActiveSheetView.GetSelections(); for (int i = cRanges.Length -1; i >= 0; i--) { FpSpread1.ActiveSheetView.RemoveRows(cRanges[i].Row, cRanges[i].RowCount); } } } 复制代码源码下载:VS2010 + Spread 6.0.3505