Drawing by filling in grid squares

jbs30000

New member
Joined
Sep 7, 2009
Messages
3
Programming Experience
5-10
Hello, I just have a quick question. In graphics drawing programs like icon editors where you draw by holding down your mouse button and moving your mouse over squares in a grid which causes them to be filled with a chosen color, what is the control that's used?

Looking at the controls I can add to a form, none of them seem to be what I'm looking for. Or is it something like using a picture box, drawing a grid, then when the mouse button is down checking the position of the mouse to see which square it's over and filling in the square? Thanks.
 
I asked somebody else who made an image editor in the way I described and he said he used a DataGridViewControl, which is what I was thinking.

But I'm not quiet sure what code to use. I've done a lot of Googling, but I can't find anything on the subject.
 
Last edited:
Hi jbs,

I don't think there is a ready-made control for this way of drawing (I think they used to call it FatBits). A DataGridView would be excessively complicated in my view, because it is designed to interact with a database. You might be able to do something with a TableLayoutPanel. But I expect that would end up being more difficult than programming the grid yourself in a PictureBox. I can help you if you need some hints about doing it that way.

cheers, VicJ
 
Last edited:
After more research I finally found that I could use the cellclick or cellmousedown event, use e.ColumnIndex and e.RowIndex to see which cell was clicked, and then use .Item(column, row).Style.BackColor = color to set the background color.

I'm sure there are probably better methods, but since I can't seem to find any, I guess I'll stick with this.
 
Back
Top