|
-
Mar 9th, 2012, 02:32 PM
#1
Thread Starter
Member
Click DataGridView cell, change its background image
Hello,
I'm trying to make a visual map editor, and figured that a DataGridView would be the best way to go. I would like to make it so that you can click one of many buttons to set which new image the grid cell will be set to when you click it.
I've set up pretty much everything except that I can't figure out how to set the background image of the cell that I clicked.
Image:
http://www.dreamvalleygame.com/uploa...pGenerator.png
--
TL;DR:
How do I change the background image of the individual cell I click in a DataGridView?
--
The grid was created programmatically.
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Set SelectedEntity
SelectedEntity = Black
'Just number
Dim n As Integer = 0
'Add 80 columns
For n = 1 To 80
Dim newCol = New DataGridViewImageColumn
'Set default image to a wall
newCol.Image = Black
'Stretch the image to fit so it looks nice
newCol.ImageLayout = DataGridViewImageCellLayout.Stretch
'Set the width to look nice and pretty
newCol.Width = 20
'Set the number of the column for easier reading
newCol.HeaderText = n.ToString
'Add the column
DataGridView1.Columns.Add(newCol)
Next
'Add 60 rows
DataGridView1.Rows.Add(60)
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|