问题
I've written a bunch of handy Excel add-ins in C#, and everything works great. But the one thing I haven't been able to figure out is if it's possible to place graphics (bitmaps, shapes, whatever) on a worksheet control, e.g. by appending a function to its paint event handler.
I don't want to actually change the document in any way, it's only for temporarily highlighting things to indicate how my add-ins are finding and interpreting data in the sheet. The simplest thing I want to be able to do is draw a border around a specific range.
I could do it by creating a bunch of transparent top-level windows that try to clip themselves to the document window, but that's really a nasty solution, and I'm thinking the windows would get in the way of user input, too.
回答1:
It's late answer, but for future readers I think it's worth to clarify. There is no way to use paint event to draw anything on the top of Excel. But there is built in way to highlight a range or many ranges at the same time - just select it from code.
来源:https://stackoverflow.com/questions/5952032/vsto-drawing-on-top-of-excel-worksheet