简体   繁体   中英

VSTO: Drawing on top of Excel worksheet

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, eg 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM