我正在嘗試爲Spread.NET創建自定義單元格類型。我得到的錯誤是無法調用抽象基礎成員
無法調用抽象基成員: 「FarPoint.Web.Spread.BaseCellType.PaintCell(字符串, System.Web.UI.WebControls.TableCell,FarPoint.Web.Spread.Appearance , FarPoint.Web.Spread.Inset,對象,布爾)」
下面的代碼
[Serializable()]
public class BarcodeCellType : FarPoint.Web.Spread.BaseCellType
{
public override Control PaintCell(string id, TableCell parent, Appearance style, Inset margin, object value, bool upperLevel)
{
parent.Attributes.Add("FpCellType", "BarcodeCellType");
if (value != null)
{
try
{
MemoryStream ms = GenerateBarCode(value.ToString());
var img = Bitmap.FromStream(ms);
value = img;
}
catch (Exception ex)
{
value = ex.ToString();
}
}
return base.PaintCell(id, parent, style, margin, value, upperLevel); //ERROR HERE
}
private MemoryStream GenerateBarCode(string codeInfo)
{
using (MemoryStream ms = new MemoryStream())
{
BarCodeBuilder bb = new BarCodeBuilder();
bb.CodeText = codeInfo;
bb.SymbologyType = Symbology.Code128;
bb.BarCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
return ms;
}
}
}
基礎方法是否是虛擬的,並且與您的覆蓋具有相同的簽名? – twrowsell
只是擡頭,你有內存泄漏。你的MemoryStream和位圖的實例應該通過調用Dispose()完成之後清理它們,或者在「使用」塊中包裝它們。 –
嗨mjmarsh - 我更新了我的代碼。你是否在做這樣的事情? – daved