Results 1 to 13 of 13

Thread: [RESOLVED] Customize Common Dialog

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] Customize Common Dialog

    I use common dialog.

    an my data is in c:\Project\Data.

    When I hit the Insert button, the common dialog come out at the specific path location

    Code:
    CommonDialog1.InitDir = "c:\Project\data"
    but it able to browse the data at other path location by using drop down menu in look in combo box.How to disable the drop down menu in look in combo box?I just want it able to access the spesific location in folder directory.Have an Idea?
    Attached Images Attached Images  
    Last edited by matrik02; May 22nd, 2007 at 12:55 AM.

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Customize Common Dialog

    If you don't want the user to change folders use the FileListBox control.

    vb Code:
    1. 'Set path
    2. File1.Path = "C:\"
    3.  
    4. 'set file types to be displayed
    5. File1.Pattern = "*.exe"

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Customize Common Dialog

    Thank yo, I got some idea from your answer.

    My data is in directory c:\Project\Data

    Actually in Data folder, it have other directory.

    So I choose to use DirListbox and FileListBox

    All data are store in data folder.

    The Question is, if I use DirListbox, I don't want the user access other directory outside the c:\Project\Data, The user are allow to access the directory inside the Data folder.However, if use DirListbox, the user still able to browser in C: directory. I just want the user able to browse and access the directory and folder inside this location c:\Project\Data.

    Code:
    Dir1.Path = "C:\Project\Data"
    Attached Images Attached Images  

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Customize Common Dialog

    Try this
    Code:
    Private Sub Form_Load()
    Dir1.Path = "C:\Project\Data"
    File1.Path = Dir1.Path
    End Sub
    They can click around all they want to, but if you don't put the code it to respond to the clicks they aren't going anywhere.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: access directory

    Actually, When I use Dirlistbox and filelistbox, I able to access the data folder and the data file inside the data folder. This fine and allow it . I don't want the user access the data file outside of the path location C:\Project\Data by click dirlistbox and select C:\ . This method able the user to browse the data outside of the specific path location for example C:\Windows.

    I want the users are allow to access the data folder and the directory inside the path location C:\Project\Data only.Have any idea?

    Code:
    Private Sub Dir1_Change()
    
    File1.Path = Dir1.Path
    
    End Sub
    
    
    Private Sub Form_Load()
    Dir1.Path = "C:\Project\Data"
    File1.Path = Dir1.Path
    End Sub
    Attached Images Attached Images  
    Last edited by matrik02; May 22nd, 2007 at 07:44 AM. Reason: for get to attach the image

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Customize Common Dialog

    Remove this
    Code:
    Private Sub Dir1_Change()
    
    File1.Path = Dir1.Path
    
    End Sub
    Don't let them do that. Only use the code in the Form Load.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Customize Common Dialog

    Now, I cannot see the data in the filelistbox inside the data folder. For you information, I want the user also able to access all directory and its file as long as the the directory are inside the data folder

    for example C:\Project\Data\Soil, C:\Project\Data\Map C:\Project\Data\Nutrient, C:\Project\Data\Ma\P

    At the moment, I just able to see the data file in data folder but not able to see the data file inside the data folder directory example C:\Project\Data\Map

    User are not allow to see and access all data file in its directory execept the the data store in the location C:\Project\Data and it directory, Folder name 'DATA' iin the path location C:\Project\Data act as a parent in this case.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Customize Common Dialog

    If you permit them to open one folder, then they are going to be able to open them all.

    May I ask why you don't want them outside of this folder structure?

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Customize Common Dialog

    because I want to make it easier to find the data at the spesific location and browse the data inside the data folder only.

    If I remove it, I unable to see the file inside the C:\Project\Data\K for example.

    Code:
    Private Sub Dir1_Change()
    
    File1.Path = Dir1.Path
    
    End Sub
    At the moment, I am able to see the file in the C:\Project\Data only.

    If I don't remove the code below, I can able to browse the file inside C:\Project\Data but also able to see the data file outside the folder structure.
    Code:
    Private Sub Dir1_Change()
    
    File1.Path = Dir1.Path
    
    End Sub
    I don't want them browse outside of this folder structure

    here all the code

    Code:
    Private Sub Form_Load()
    Dir1.Path = "C:\Project\Data"
    File1.Path = Dir1.Path
    End Sub
    Last edited by matrik02; May 22nd, 2007 at 09:00 AM.

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Customize Common Dialog

    As I said
    Quote Originally Posted by Hack
    If you permit them to open one folder, then they are going to be able to open them all.
    As I asked
    Quote Originally Posted by Hack
    May I ask why you don't want them outside of this folder structure?

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Customize Common Dialog

    Sorry if my english is not good enough to able you to answer my questions

    Aswser question 1

    Originally Posted by Hack
    If you permit them to open one folder, then they are going to be able to open them all.
    If I permit the to open one folder in the form load
    Dir1.Path = "C:\PROJECT\Data", I able to see the file of the Data folder in filelistbox. But If change the directory in the Dirlistbox for example C:\PROJECT\Data\K, the file of that folder is not change in filelistbox. It still remain.


    Answer question for question 2

    because I want to make it easier to find the file at the spesific location and also able to browse the directory of the folder inside data folder only.

  12. #12
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Customize Common Dialog

    Try this
    Code:
    Private Sub Dir1_Change()
    If Dir1.Path = "c:\" Then
       Dir1.Path = "C:\PROJECT\Data\"
    Else
       File1.Path = Dir1.Path
    End If
    End Sub

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Customize Common Dialog

    Thank you so much your are a great man


    Code:
    Private Sub Dir1_Change()
    If Dir1.Path = "C:\" Then
       Dir1.Path = "C:\Test\Data\"
    Else
       File1.Path = Dir1.Path
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width