dcsimg
Results 1 to 2 of 2

Thread: Drawing an arrow over a datagridview

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2016
    Posts
    93

    Drawing an arrow over a datagridview

    First let me note one thing. I don't know how to "draw" anything in vb.net (or any other language).

    Now, I would like to draw an arrow from one cell (if it matters, the center of the cell would be best) of a datagridview to another (from my limited google searches it sounds like drawing on a datagridview is hard to do, so perhaps "over" it). Can this be done and if so, how?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,661

    Re: Drawing an arrow over a datagridview

    Drawing in Windows Forms is done using GDI+. I would suggest that you start with a bit of research on that and the Paint event of the Control class, which is where GDI+ drawing is usually performed.

    In the case of a DataGridView, it's a bit more complex. The control has its own Paint event but there are related events for individual cells. If you want to draw on multiple cells, you're going to have to handle CellPainting event, detect whether the cell the being painted is one you want to draw on and, if it is, perform the appropriate drawing. That's going to require a bit of mathematics.

    Remember that you can write code that will conceptually draw outside the bounds of the current cell. What that means is that you can use basically the same code for each cell and draw the same thing each time, but use a different offset in each case, effectively displaying a different portion of the overall drawing within the bounds of each cell.

    You should also be aware that, when editing a cell, an editing control is created and embedded in the cell. In that case, it will obscure anything that you draw in the cell unless you draw on the editing control too, which may not be possible in all cases.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width