F
Fencer
Hello, I'm having problems with DataGridView I need help with. It's the
first time I use this control (and I'm struggling to wrap my head around
it) and my C# skills are rather rusty.
Anyway, I created the DataGridView like this:
grid.ColumnCount = 4;
grid.Dock = DockStyle.Fill;
grid.Parent = this;
grid.AutoSize = true;
grid.BorderStyle = BorderStyle.Fixed3D;
grid.Columns.Clear();
grid.Columns.Add(new DataGridViewImageColumn());
grid.Columns.Add(new DataGridViewImageColumn());
grid.Columns.Add(new DataGridViewImageColumn());
grid.Columns.Add(new DataGridViewImageColumn());
then I add my Rows like this:
grid.Rows.Add(new Tile[] { new Tile(), new Tile(), new Tile(), new
Tile() });
Side note: Here I actually wanted to get a row from my 2D-array of Tiles
but I couldn't make it work
Tile inherits from DataGridViewImageCell and in the constructor I set
the property "Value" to a bitmap I've loaded and that's basically it.
However, something's missing because when I run the program I get a long
string of error dialogs complaining (and here I have to translate from
my localized version):
The following exception occured in DataGridView:
System.FormatException: Cannot convert the value DataGridViewImageCell {
ColumnIndex = -1, RowIndex = -1} to the type Image...
I suspect I may need to do more things on the grid and in my Tile class,
but I'm having serious problems figuring exactly what, so I ask for the
assistance of the this group.
Thanks in advance for any help!
- Fencer
first time I use this control (and I'm struggling to wrap my head around
it) and my C# skills are rather rusty.
Anyway, I created the DataGridView like this:
grid.ColumnCount = 4;
grid.Dock = DockStyle.Fill;
grid.Parent = this;
grid.AutoSize = true;
grid.BorderStyle = BorderStyle.Fixed3D;
grid.Columns.Clear();
grid.Columns.Add(new DataGridViewImageColumn());
grid.Columns.Add(new DataGridViewImageColumn());
grid.Columns.Add(new DataGridViewImageColumn());
grid.Columns.Add(new DataGridViewImageColumn());
then I add my Rows like this:
grid.Rows.Add(new Tile[] { new Tile(), new Tile(), new Tile(), new
Tile() });
Side note: Here I actually wanted to get a row from my 2D-array of Tiles
but I couldn't make it work
Tile inherits from DataGridViewImageCell and in the constructor I set
the property "Value" to a bitmap I've loaded and that's basically it.
However, something's missing because when I run the program I get a long
string of error dialogs complaining (and here I have to translate from
my localized version):
The following exception occured in DataGridView:
System.FormatException: Cannot convert the value DataGridViewImageCell {
ColumnIndex = -1, RowIndex = -1} to the type Image...
I suspect I may need to do more things on the grid and in my Tile class,
but I'm having serious problems figuring exactly what, so I ask for the
assistance of the this group.
Thanks in advance for any help!
- Fencer