dataGridView图像不显示第一行,第二个单元格 [英] dataGridView Image not displaying for first row, second Cell
问题描述
请注意,我已经尝试过以下操作:
在启动时更改或删除我的选择;
使用不同的图像;动态设置图像(代码);和一些随机更改的设置。任何帮助将高度赞赏!我很感谢大家的帮助,请让我知道,如果我可以提供更多的信息。
code>命名空间WindowsFormsApplication1
{
public partial class Form1:Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender,EventArgs e)
{
列表< MyItem> items = new List< MyItem>(); (int i = 0; i< 10; i ++)
{
items.Add(new MyItem {Key = i,value = Image.FromFile(@e:\ test.jpg)});
}
this.dataGridView1.AutoGenerateColumns = false;
this.dataGridView1.Columns.Clear();
this.dataGridView1.Columns.Add(Key,Key);
this.dataGridView1.Columns.Add(new DataGridViewImageColumn(){HeaderText =Status});
this.dataGridView1.Columns [0] .DataPropertyName =Key;
this.dataGridView1.Columns [1] .DataPropertyName =value;
this.dataGridView1.DataSource = items;
}
}
public class MyItem
{
public int Key {get;组; }
public Image value {get;组; }
}
}
Okay so I have a dataGridView that I am trying to display an image on (using the DataGridViewImageColumn), all of the appropriate rows have the image, except for row one (this is also the only row that I can see in the visual studio's editor) The image below is what I am getting, I want all of them to be the green check mark though. How might I accomplish that?
Please note that I have already tried the following: Changing or removing my selection on start-up; Using a different image; Setting the image dynamically (in code); and a bit of randomly changing settings. Any help would be highly appreciated! I thank you all in advance for the help, please let me know if I can supply anymore information.
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
List<MyItem> items = new List<MyItem>();
for (int i = 0; i < 10; i++)
{
items.Add(new MyItem { Key = i, value = Image.FromFile(@"e:\test.jpg") });
}
this.dataGridView1.AutoGenerateColumns = false;
this.dataGridView1.Columns.Clear();
this.dataGridView1.Columns.Add("Key", "Key");
this.dataGridView1.Columns.Add(new DataGridViewImageColumn() { HeaderText="Status"});
this.dataGridView1.Columns[0].DataPropertyName = "Key";
this.dataGridView1.Columns[1].DataPropertyName = "value";
this.dataGridView1.DataSource = items;
}
}
public class MyItem
{
public int Key { get; set; }
public Image value { get; set; }
}
}
这篇关于dataGridView图像不显示第一行,第二个单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!