为了更好的解决方法,请参考本Blogspot职位。
我想为我的项目相同的解决方案,它运作良好,在我的DataGrid单元格显示16×16像素的图像,我已经编辑了以上TextandImageColumn
类的功能:
protected override void Paint(Graphics graphics, Rectangle clipBounds,
Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState,
object value, object formattedValue, string errorText,
DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{
// Paint the base content
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState,
value, formattedValue, errorText, cellStyle,
advancedBorderStyle, paintParts);
if (this.Image != null)
{
PointF p = cellBounds.Location;
p.X += 0;
p.Y += 4;
graphics.DrawImage(this.Image, p);
}
}
发表您的ASPX标记这里 – 2012-07-14 04:48:31
ref1c - 你是否在你的问题中得到行和列混淆?要对同一行的图片和文字(在不同的列)是微不足道的,只是有一个图像和文本列。有一个列和图像和文字是有点棘手。我现在正在为此做出答案。 – 2012-07-14 14:36:43