Embed a File Chooser in a UserControl / Form - c#

I've inherited a desktop application which has a custom .NET file chooser that is embedded in a control, but it has some issues.
I'd like to replace it with a non-custom File Chooser (like the OpenFileDialog).
However, for a variety of reasons it needs to be embedded in the parent control not a popup dialog.
Is there a control I'm missing, or does MS only provide the popup dialog out of the box?

The .Net control is a thin wrapper for the common dialog built into windows, and that is a dialog. So there is no way to embed it as though it were a control.

Depending on your needs, you COULD abuse the web browser control to show local files and folders. It won't match all the functionality of the OpenFileDialog, but it could work.
Here's one that I remembered from way-back. The Shell Mega-Pack. It has ActiveX and .NET versions. It looks promising.
Alternatively, if you want to build your own, you could start here on CodeProject: A Windows Explorer in a User Control. That looks like a good start. Here's another one: An All VB.NET Explorer Tree Control with ImageList Management.

Related

Need walkthrough for choose file dialog or open file dialog to appear Awesomium

Guys i have the awesomium webcontrol that was available in the toolbox and it doesnot display choose file or any dialog box for uploading files(e.g. uploading pic/video in facebook).pls give the complete procedure on how to enable it.i am using visual c# and it is a wpf application.
Some more info is needed.
Are you referring to the WinForms or the WPF WebControl?
Have you downloaded the latest RC? Download it here.
The WinForms WebControl provides all dialogs. The WPF WebControl provides all dialogs too, however, folder selection dialogs are only supported on Windows Vista and newer. If the dialogs do not appear, you may have to handle the SelectLocalFiles event. Make sure the event is fired. If it is but you still see no dialog, handle the event yourself and display your own modal dialog. Provide the result to FileDialogEventArgs.SelectedFile or FileDialogEventArgs.SelectedFiles and don't forget to set FileDialogEventArgs.Handled to true.
What version of Awesomium? You need probably 1.7RC2 which has modal dialog boxes.

c# save contents of IE browser as html

I have an Internet Explorer window open. The title of this window will always be "test123"
how do I save the source of the contents of the window as an HTML file?
Please note that the process should not be to open a URL and read the HTML into a variable. I absolutely HAVE TO do it the way I described since I need to login to a site to be able to view the HTML that I want to save.
**if it makes it easier to do this through my winform and putting a webbrowser control on it, that is fine as well.
You can attach to virtually any Windows app, using managed code and the UI Automation classes. Not a lot of people know about this stuff.
Microsoft shipped a class library and runtime that allows applications to automate other Windows on the system. You can do things like click buttons, read textboxes, activate menus, and so on. Here's a quick intro.
It should be relatively simple to attach to an IE Window, and then programmatically tickle the File...Save As... menu option.
I did this the other day for a Paint.NET app. It took much less time that I thought it would.
But I agree it's probably easier to use a WebBrowser control in a regular app, to programmatically retrieve content. You could also use the System.Net.WebClient class to do it, if you don't need to show the HTML content.
If you embed a WebBrowser control inside of your WinForm you can do this:
webBrowser1.Navigate("http://StackOverflow.com");
string pageHtml = webBrowser1.Document.GetElementsByTagName("html")[0].InnerHtml;
This will return all of the HTML in the page navigated to.

Integrating a WPF control in WinForms without allowing access to other WPF controls?

I need the DocumentViewer WPF control (for XPS files) in a Windows Form application. This is actually simple, but I'm not allowed to link in WPF assemblies. My boss' reasoning is that people will start using WPF controls which are incompatible with some of our software. I can't change any of this; it has to be XPS and cannot bring in more than one WPF control. I can use this control if I had a way to link it and only it (no other WPF controls/classes) to our software.
Is it possible for me to write some sort of wrapper on the control in a WPF Class library, and then import that DLL but the DLL does not allow access to other WPF controls? Is there a way for me to extract just that WPF control from the Presentation Framework assembly (probably not, and this sounds like something that violates the EULA)?
Or does anyone have a different approach they would like to suggest?
And no, not PDF please.
Just make a class library that does nothing but exposes a (Windows Forms) UserControl. Inside of this UserControl, put your ElementHost with the DocumentViewer. This way, you'll only load your project's UserControl, and the "WPF Controls" are isolated in the separate project.

Does WPF have a control for browsing the local file system?

I would like to add a control to my app where the user can browse his local file system and select a directory. I would prefer to host this control on my main app window, and not do this via a pop-up dialog.
There isn't one built in.
You can either use the WinForms file/folder browser, search Code Project or similar site for someone else's implementation or write your own.
I've found one on Ookii Dialogs that includes some other standard dialogs.
If you want to host the controls on your own form, use controls from Shell MegaPack.WPF

How to create an Explorer-like folder browser control?

Using C# and WinForms in VS2008, I want to create a file browser control that looks and acts like the left pane in Windows Explorer. To my astonishment, such a control does not ship with .NET by default.
Ideally, I would like its contents to be exactly the same as in Explorer. For example, on Windows 7, it should show the Favorites and Libraries pseudo-folders. Of course, I do not want to code specifically for each version of Windows if I can help it.
I have browsed around, and there are some examples of such controls, but they are all hand-rolled and therefore won't work 100% the same as the one in Explorer.
Is there any way I can simply reuse the Explorer control instead? Or, if not, to get access to a tree of the items that it would show?
Microsoft provides a walkthrough for creating a Windows Explorer style interface in C#.
There are also several examples on Code Project and other sites. Immediate examples are Explorer Tree, My Explorer, File Browser and Advanced File Explorer but there are others. Explorer Tree seems to look the best from the brief glance I took.
I used the search term windows explorer tree view C# in Google to find these links.
It's not as easy as it seems to implement a control like that. Explorer works with shell items, not filesystem items (ex: the control panel, the printers folder, and so on). If you need to implement it i suggest to have a look at the Windows shell functions at http://msdn.microsoft.com/en-us/library/bb776426(VS.85).aspx.
Take a look at Shell MegaPack control set. It provides Windows Explorer like folder/file browsing with most of the features and functionality like context menus, renaming, drag-drop, icons, overlay icons, thumbnails, etc

Categories

Resources