を割り当てDataGridViewCellFormattingEventHandler
インサイド
は、このBlogspot記事を参照してください。
が、私は私のデータグリッドセルに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マークアップを投稿しますref1c - あなたの質問に混乱している行と列がありますか?同じ行(異なる列にある)にイメージとテキストを置くのは簡単ですが、イメージとテキスト列があります。イメージとテキストの両方で1つの列を作成するのはちょっと面倒です。私は今、その答えに取り組んでいます。 –