tags:

views:

1452

answers:

3

How can the OpenFileDialog View Menu be set to Detail View?

A: 

Quick google search reveals this:

http://forums.microsoft.com/Forums/ShowPost.aspx?PostID=3843682&SiteID=1

In particular it suggests:

Dim OpenFileDialog1 As New OpenFileDialog
SendKeys.Send("{tab}{tab}{tab}{tab}{tab}{right}{right}{down}{up}{enter}")
OpenFileDialog1.ShowDialog()

Which is bad. It futher recommends finding the handle of that dialog and sending the key presses directly to that. You would also need to be aware that the solution could quite possibly break in different versions of windows.

It may be useful depending on your situation (though I do feel evil for posting this!)

DaEagle
sending key while the dialog is not even there? you sure it would work?
Fredou
The MSDN post says the question is answered so I'd assume it works.
DaEagle
+1  A: 

someone did it here, with the win32 api

DefaultViewMode:

This property lets you choose which view the OpenFileDialog should 
start in; by default, it opens using the “Details view”. Here you 
can specify a different default view like Icons, List, Thumbnail, Detail, etc
Fredou
A: 

Do not use Senkeys command at all. especially if your program is running in Windows Vista.

Using SendKeys is not recommended because you cannot be completely certain that the key presses will be sent to the correct place as they will be sent to the first window that appears that can accept them. In this case there is probably little risk but generally SendKeys should be avoided if you can.

AJ