vb.net(fw4.6)でファイル選択ダイアログ(OpenFileDialog)を使ってファイルを指定しておりますが、ダイアログの初期表示スタイルを、細かく指定する事はできるでしょうか?
例えば、、
・必ず詳細一覧(グループで表示とかも切りたい)
・必ず更新日時降順
などです。
調べ方のヒントなどでもかまいませんので情報をお願いいたします。
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。

回答2件
0
ベストアンサー
https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.forms.openfiledialog?view=netcore-3.1
>このクラスのコア機能のほとんどは、FileDialogクラスにあります。
openfiledialogはFileDialogを継承している様です。
https://www.weblio.jp/content/FileDialog.Options+プロパティ
>OptionsプロパティはWin32 を使用してファイルダイアログボックスを
>初期化するために使用するフラグに対応しています。
>FileDialogクラスのプロパティを使用するとオプションを
>取得または設定できます。
とありますので、Optionsの設定を変更するとできるのかも知れません。
(やり方を見つける事は出来ませんでした。)
参考までに:VB.NET用GetOpenFileNameのAPIは下記。
ofn.flags = &H200 Or &H20000の部分を変えると色々と画面は変わります。
flag説明、https://teratail.com/questions/261992#reply-377083
その他のflag解説はVB6側での資料が多い様です。
参考hp:https://www.pinvoke.net/default.aspx/comdlg32/GetOpenFileName.html
Option Strict Off Imports System.Runtime.InteropServices Public Class App <DllImport("comdlg32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Private Shared Function GetOpenFileName(<[In](), Out()> ByVal ofn As OpenFileName) As Boolean End Function <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _ Public Class OpenFileName Public structSize As Integer = 0 Public dlgOwner As IntPtr = IntPtr.Zero Public instance As IntPtr = IntPtr.Zero Public filter As String = Nothing Public customFilter As String = Nothing Public maxCustFilter As Integer = 0 Public filterIndex As Integer = 0 Public file As String = Nothing Public maxFile As Integer = 0 Public fileTitle As String = Nothing Public maxFileTitle As Integer = 0 Public initialDir As String = Nothing Public title As String = Nothing Public flags As Integer = 0 Public fileOffset As Short = 0 Public fileExtension As Short = 0 Public defExt As String = Nothing Public custData As IntPtr = IntPtr.Zero Public hook As IntPtr = IntPtr.Zero Public templateName As String = Nothing Public reservedPtr As IntPtr = IntPtr.Zero Public reservedInt As Integer = 0 Public flagsEx As Integer = 0 End Class 'OpenFileName Public Class LibWrap 'BOOL GetOpenFileName(LPOPENFILENAME lpofn); Declare Auto Function GetOpenFileName Lib "Comdlg32.dll" ( _ <[In](), Out()> ByVal ofn As OpenFileName) As Boolean End Class 'LibWrap Private Function Test_Sample_Miniature( _ Optional ByVal filter As String = ("All files" & ChrW(0) & "*.*" & ChrW(0)), _ Optional ByVal title As String = "Open File Dialog...", _ Optional ByVal defext As String = "*", _ Optional ByVal path As String = "C:\") As String Try Dim ofn As New OpenFileName '=========================== ofn.flags = &H200 Or &H20000 '=========================== ofn.structSize = Marshal.SizeOf(ofn) ofn.filter = filter ofn.file = New String(New Char(256) {}) ofn.maxFile = ofn.file.Length ofn.fileTitle = New String(New Char(64) {}) ofn.maxFileTitle = ofn.fileTitle.Length ofn.initialDir = path ofn.title = title ofn.defExt = defext If LibWrap.GetOpenFileName(ofn) Then Console.WriteLine("Selected file with full path: {0}", ofn.file) Console.WriteLine("Selected file name: {0}", ofn.fileTitle) Console.WriteLine("Offset from file name: {0}", ofn.fileOffset) Console.WriteLine("Offset from file extension: {0}", ofn.fileExtension) Return ofn.file End If Catch ex As Exception Debug.Assert(False) Return System.String.Empty End Try Test_Sample_Miniature = "" End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Call Test_Sample_Miniature() End Sub End Class
投稿2020/05/24 00:55
編集2020/05/24 06:52総合スコア553
0
そういう設定プロパティは無いので、OpenFileDialogでは無理かと思われます。
Shell32のCOMでエクスプローラーを直接操作するような事をやってる人が居ますが、詳しいドキュメントがないので、かなり大変そうです。
エクスプローラーのフォルダの並び順を取得する
エクスプローラでフルパス名検知
投稿2020/05/23 05:40

退会済みユーザー
総合スコア0
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。

退会済みユーザー
2020/05/23 10:02

あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/05/24 01:40
2020/05/29 07:18