Wednesday, August 19, 2009

.NET CF Open File Dialog and Folder Dialog

ah, probably the first annoying Windows Mobile control. As a first time developer for Windows Mobile, I found this control, very very very inconvenient to use. I was actually developing something in Windows Mobile and I haven’t gone far on it and I have to use OpenFileDialog and that control crashes my plans.

would you like to say hello?
image image
iiiiiyuuccck!
Who in Microsoft Windows Mobile team make some stupid control like that? I can’t browse for subfolders!! What a lazy developer! So I made up my mind and decided to make my own. I actually made 2 controls.

NETCFOpenFileDialog and NETCFFolderDialog

Here are the screen shots and Code Snippets.

I made a test form so I can see the result after calling the forms
image

NETCFOpenFileDialog + NETCFFolderDialog Control

image image image
image image image
image image
the file extension automatically adds to File Type dropdown.
Doesn’t look like the control familiar to you?

:)

Code Snippet

NETCFOpenFileDialog.OpenFileDialog ofd = new NETCFOpenFileDialog.OpenFileDialog();
ofd.DefaultPath = @"\Windows\Start Menu\Programs";
ofd.Title = "Open File Test";
ofd.Filter = "JPG|*jpg;PNG|*.png;ALL FILES|*.*";
ofd.OpenDialog();

if (ofd.Filename != string.Empty)
{
txPath.Text = ofd.Filename;
}

NETCFFolderDialog

image  

Code Snippet

NETCFFolderDialog.FolderDialog ofd = new NETCFFolderDialog.FolderDialog();
ofd.DefaultFolder = @"\Windows\Start Menu\Programs";
ofd.OpenDialog();

if (ofd.Folder != string.Empty)
{
txFolder.Text = ofd.Folder;
}

Download the binaries here
NETCFOpenFileDialog.zip

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.