Question

I'm primarily an asp.NET MVC dev, but I've inherited a WinForms app to maintain and enhance. One of its features is a reporting window that is simply a WinForm with a BrowserPanel control into which a lot of angle brackets and text is injected. The report is simply a set of HTML tables.

My 'problem' is that the reports form with the BrowserPanel in it, by virtue of being a pop-up form, is modal. I think I understand why it's best not to try to make it a non-modal WinForm, but it would be nice if the report window could be open while the user is in other parts of the app.

So when the user wants to see a report, instead of using this WebForm/BrowserPanel paradigm, could I just send all the report HTML to the user's browser instead of using a BrowserPanel in a WinForm? Or is that just a really bad idea? If it's an okay idea, how might I do something like that?

Many thanks for your time.

Was it helpful?

Solution

Without seeing the application working I'm not sure if its a good or bad idea - WebBrowser controls in Winform apps do have certain pro's (and con's). It is so simple to do, give it a go and see if its what the users want - even if its ends up as an program setting:

//Save the HTML to a file
string fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\a.html";
System.IO.StreamWriter file = new System.IO.StreamWriter(fileName);
file.WriteLine(htmlContent);
file.Close();

//Open the HTML file in the default browser
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = fileName;
Process myProcess = Process.Start(start);

The Form Property TopMost would allow you to have a non-modal window that is always on top.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top