【发布时间】:2014-01-20 16:26:57
【问题描述】:
我正在尝试为 Spread.NET 创建自定义单元格类型。我得到的错误是
不能调用抽象基成员: 'FarPoint.Web.Spread.BaseCellType.PaintCell(字符串, System.Web.UI.WebControls.TableCell,FarPoint.Web.Spread.Appearance, FarPoint.Web.Spread.Inset, object, bool)'
这是代码
[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;
}
}
}
【问题讨论】:
-
基本方法是虚拟的并且与您的覆盖具有相同的签名吗?
-
请注意,您有内存泄漏。您的 MemoryStream 和 Bitmap 实例应在完成后调用 Dispose() 或将它们包装在“使用”块中进行清理
-
嗨 mjmarsh - 我更新了我的代码..你的意思是做这样的事情吗?