2008-12-05 23 views

回答

0

快速谷歌搜索發現這一點:

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

尤其是它表明:

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

這是壞的。它還建議找到該對話框的句柄,並直接將按鍵發送到該對話框。您還需要意識到,該解決方案很可能會在不同版本的Windows中破解。

這可能是根據您的情況非常有用(雖然我覺得邪惡張貼這個!)

+0

發送密鑰,而對話框甚至沒有?你確定它會工作? – Fredou 2008-12-05 01:18:10

2

有人做到了here,與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 
0

不要使用Senkeys命令不惜一切。特別是如果您的程序在Windows Vista中運行。

不推薦使用SendKeys,因爲您不能完全確定按鍵將被髮送到正確的位置,因爲它們將被髮送到出現的可以接受它們的第一個窗口。在這種情況下,可能幾乎沒有風險,但通常SendKeys應儘可能避免。