Windows Forms above Excel

I have a form that emerges from an excel add-on written with VSTO. I would like the form to always remain above the Excel spreadsheet, but still allows the user to interact with the sheet below it.

The constructor of the forms includes this.TopLevel = true; , but the form still disappears behind the spreadsheet when selecting a cell.

Has anyone else encountered this problem and found a workaround?

+4
source share
2 answers

The form already has a TopLevel value of true. Do you want TopMost.

P / Invoking SetParent () would be best, but getting the required window handle might not be that simple. Maybe Process.GetCurrentProcess (). MainWindowHandle

+4
source

if you want to have an interactive form in Excel, you will need to make some kind of conclusion, as Hans said in the original answer. see this link on MSDN

This example is for the refedit control (which is usually only available from VBA). In this example, you need to provide the necessary information about IWin32Window and pinvoking to call the Show method of the form object with this parameter value.

0
source

Source: https://habr.com/ru/post/1313901/


All Articles