CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2001
    Location
    Salt Lake City, UT
    Posts
    135

    Problem with Common Dialog Control

    I am having a problem using the Filter property of the common dialog control. When I try to add a filter, i get the following compile error "Invalid use of property"
    Is there any reason for this? does the filter property have to be set in the Form_Load event?
    This is what I have:

    private Sub cmdOpenFile_Click()
    on error resume next
    CommonDialog1.Filter "FoxPro Programs (*.prg)|*.prg"
    CommonDialog1.ShowOpen
    me.txtFileName = CommonDialog1.FileName
    me.lstPrgFiles.AddItem (CommonDialog1.FileName)
    End Sub




    Thanks!

    ~goddess
    [email protected]
    "There are no stupid questions, but there are a lot of inquisitive idiots."

  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Problem with Common Dialog Control

    The problem I believe is not in Filter but in the line
    me.lstPrgFiles.AddItem (CommonDialog1.FileName)

    if you use CommonDialog1.FileName
    then you will get the message - invalid use of property

    try the following

    r = CommonDialog1.FileName

    me.lstPrgFiles.AddItem r

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Apr 2001
    Location
    Salt Lake City, UT
    Posts
    135

    Re: Problem with Common Dialog Control

    I tried your suggestion, but I still get the same error on the filter property.
    Is there anything else I can try?

    ~goddess
    [email protected]
    "There are no stupid questions, but there are a lot of inquisitive idiots."

  4. #4
    Join Date
    May 2001
    Location
    Canada
    Posts
    182

    Re: Problem with Common Dialog Control

    Maybe it is just a type error. I found you missed '='.

    CommonDialog1.Filter = "FoxPro Programs (*.prg)|*.prg"

    Regards,

    Michi

  5. #5
    Join Date
    Apr 2001
    Location
    Salt Lake City, UT
    Posts
    135

    Re: Problem with Common Dialog Control

    Thanks! This worked great.

    ~goddess
    [email protected]
    "There are no stupid questions, but there are a lot of inquisitive idiots."

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

Featured