Recently, I met a curious thing on VisualStudio.
It was related display orders.
When I created a code which can be popupping up Excel, the behaviors were different between VisualStudio and non VisualStudio.
The code is like writing in a form's caption after Excel pops up.
Start on a windows form project and add the reference setting of "Microsoft Excel 14.0 Object Library" in COM tab.
Then adding a button with VisualStudio and paste the below code on the button's codebehind.
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook workbook = excel.Workbooks.Add(Type.Missing);
Microsoft.Office.Interop.Excel.Worksheet sheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.ActiveSheet;
((Microsoft.Office.Interop.Excel.Range)sheet.Cells[1, 2]).Value2 = string.Empty;
excel.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlMaximized;
excel.Visible = true;
this.Text = "End";
If this is waked up from VisualStudio and press the button, the Excel might be appearing in front of the form.
However quitting VisualStudio and launch it as Exe, the Excel is supposed to go behind the form.
Does anyone explain why such things happened?
Or something my environment was broken?
My environment:
Windows 7 Professional
Microsoft Excel 2010
VisualStudio 2010