473,702 Members | 2,767 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OpenFileDialog - how to select files by coding???

I’m using OpenFileDialog class in a specific InitialDirector y and I want that
files will be selected in the opened dialog when I call ShowDialog().
Actually I wish to select all files in the directory automatically by code.

Is it doable?
How??

--
Regards
Sharon G.
Nov 16 '05 #1
4 8657
Sharon,

I don't believe that this is possible. You might be able to hack it by
getting the window handle for the file dialog and then getting the handle
for the listview, and then sending the message to select every item, but
that would seem excessive.

Does the possibility exist that only some files in the directory would
be selected, or will they always be selecting all of the files in the
directory? If it is the latter, then you might want to consider using a
DirectoryBrowse Dialog (I believe that is what it is called), as it will let
you select directories.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Sharon" <Sh****@discuss ions.microsoft. com> wrote in message
news:6A******** *************** ***********@mic rosoft.com...
I'm using OpenFileDialog class in a specific InitialDirector y and I want
that
files will be selected in the opened dialog when I call ShowDialog().
Actually I wish to select all files in the directory automatically by
code.

Is it doable?
How??

--
Regards
Sharon G.

Nov 16 '05 #2
Sharon,

When you want to have all files why are you than using OpenFileDialog and
not just

DirectoryInfo
http://msdn.microsoft.com/library/de...snametopic.asp

A sample to get those filenames is in this link.

I hope this helps?

Cor
Nov 16 '05 #3
Eventually I'm using the native API FindWindow() ans SendMessge(), but I can
find what message to send to the Form.ListBox.
Can anybody tell me how to complete and fix the following call so the
ListBox will select all files in it?

SendMessage(lis tviewHandle, 0x0111, ...

I already obtained the listviewHandle but all other parameters are missing
for me, especially I need the actual value of the message, like 0x702e for
Tiles view.

Nov 16 '05 #4
Ok, I have the answer:

[DllImport("user 32.dll", EntryPoint="Sen dMessageA",
CallingConventi on=CallingConve ntion.StdCall,C harSet=CharSet. Ansi)]
private static extern uint SendMessage(uin t Hdc, uint Msg_Const, uint
wParam, uint lParam);

[DllImport("user 32.dll", EntryPoint="Fin dWindowExA",
CallingConventi on=CallingConve ntion.StdCall,C harSet=CharSet. Ansi)]
private static extern uint FindWindowEx(ui nt hwndParent, uint
hwndChildAfter, string lpszClass, string lpszWindow);

protected override void WndProc(ref Message m)
{
// Leting the Form take care off all messages.
base.WndProc(re f m);

if( m.Msg == 289 ) // Notify of message loop
{
uint dialogHandle = (uint)m.LParam; // Handle of the file dialog

if( dialogHandle != m_lastDialogHan dle ) // Only when not already changed
{
// Getting the handle of the ListBox in the OpenFileDialog dialog.
uint listviewHandle = FindWindowEx(di alogHandle, 0,
"SHELLDLL_DefVi ew", "");

// Sending message to the ListBox to set the view to Thumbnails
//Icons=0x7029, List=0x702b, Details=0x702c, Thumbnails=0x70 2d,
Tiles=0x702e
SendMessage(lis tviewHandle, 0x0111/*WM_COMMAND*/, (uint)0x702d, 0);

// Sending message to the ListBox to select all items.
SendMessage(lis tviewHandle, 0x0111/*WM_COMMAND*/, (uint)0x0001702 1,
(uint)0);

// Remember last handle
m_lastDialogHan dle = dialogHandle;
}
}
}
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2102
by: Winfree | last post by:
Hi all, i have made a page with several photos of a party. There is a index in the page, and under each thumbnail there is a checkbox. With them people can select the photos that he's going to download, but i don't know how i can send the selected photos. I think "compress" all the selected photos in a file and send it, but i couldn't do it. I used zlib and bz2 libraries, but i dont know how i can put more than one file, and even with an...
11
2292
by: Mr. B | last post by:
If you can set the 'initial' path of an OpenFileDialog box by something like the following: Dim FilesPath As String ' Files Path FilesPath = "P:\Projects\" FilesPath = OpenFileDialog1.InitialDirectory HOW can you set a 'current' path? For example:
2
1870
by: Piotrek Stachowicz | last post by:
Hi, Is there any way how can I select more than 1 file in the OpenFileDialog?! It would be really greate if I could also select a directory, click open, and recevice all the files in that directory in my application. Piotrek
1
1549
by: Jan | last post by:
Hi there, I have the following problem: Is there a way to select files on time or date. I mean on the time that they are saved. I have a lot of files with a certain save time/date. Thx
4
731
by: Chuck Edgeworth | last post by:
I'm trying to be able to select a combination of files and folders. When I try to use the OpenFileDialog it will allow me to select them but when I press the Open button it only informs me of the files I chose not the folders as well? Am I missing something? I know Microsoft can determine the folders that are selected because if you do this with the Explorer file open it will bring up windows with the contents of the folders you selected...
0
1054
by: =?Utf-8?B?V2lsbGlhbSBGb3N0ZXI=?= | last post by:
Good evening all, I was wondering if anyone knows how to exclude files from an OpenFileDialog object; for example if I want to find all *.TXT files except those starting with A; usually to find the files I would type: Text Files|*.TXT; but I have no idea how to exclude those that start with A. I have checked the help, communities and MSDN without success; so if anyone knows how to do this please let me know.
0
1529
by: Baileyboo936 | last post by:
Hi I am looking for some help with my code. I am very new to Visual Basic .Net. What I am trying to do is have a button that will allow me to select the directory and the files that I want to copy(source). I would have to have a list of files display back into a text box. Then I would have several other buttons to select different directories where I want to have the files copied to (destinations). I attached a copy of my code and a...
2
2265
by: Daveryaaziem | last post by:
This is what I am looking for. So I will basically have two databases. One with the questions and one with the answers. Each database will have several tables. For example questions in database 1 table 2 will have corresponding answers in database 2 table 2. I would like a script that will randomly select a question from a table in database 1 and depending on which table it randomly selected the question from, it will then automatically go to...
1
1771
by: Deepak Ethiraja | last post by:
For a basic application developed in VB.NET, I used the OpenFileDialog to browse and select a file. For some unknown reason, I'm unable to get the auto-populate file list work on Windows XP SP 3 (as shown in the attached image), it works fine on my Windows 7 64bit computer and my co-workers Windows XP computer. The problem is specific to one PC. I know it's a Windows XP issue but I didn't have much luck in finding any relevant solution...
0
8652
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9089
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8983
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8940
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6575
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5907
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4412
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2036
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.