افزودن تصویر در جلوی هر سطر Datagridview
کد:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.dataGridView1.Columns.Add("Column1", "Column1");
this.dataGridView1.Columns.Add("Column2", "Column2");
this.dataGridView1.Columns.Add("Column3", "Column3");
DataGridViewImageColumn img = new DataGridViewImageColumn();
Image image = Image.FromFile(Application.StartupPath + "\\0079.png");
img.Image = image;
img.HeaderText = "Image";
img.Name = "img";
dataGridView1.Columns.Add(img);
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
}
}
}
خروجی به شکل زیر میشه