2 Replies - 2133 Views - Last Post: 21 January 2011 - 03:31 AM Rate Topic: -----

#1 tendaimare  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 170
  • Joined: 04-November 10

adding an extension for save dialog

Posted 21 January 2011 - 01:14 AM

I am using this code to to generate a crystal report from aa sql string that i construct using a supplied table name and some column names in txtSQL.This code contains functionality to export to ms word.However when the save dialog comes up and the user enters the intended filename.and saves the document.when the user attempts to open the document they have to use"open with" because the save dialog does not add an extension to the file so my question is how can i add an extension for tthe user programmatically.This is my first time using save dialog


 Dim rpt As New MembersReport()
            sfdSaveMe.ShowDialog()
            Dim strExportFile As String = sfdSaveMe.FileName

            Dim sql_personnel As String = procesSQL(txtSQL.Text, cmbTableName.Text)
            Dim dt As New DataTable
            dt = MyFormz.cl_Class.SelectRows_B(sql_personnel, "CMS2010051005")

            ReportTitle = rpt.ReportDefinition.Sections(0).ReportObjects("txtReportTitle")
            ReportTitle.Text = strTitle

            rpt.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
            rpt.ExportOptions.ExportFormatType = ExportFormatType.WordForWindows
            Dim objOptions As DiskFileDestinationOptions = New DiskFileDestinationOptions()
            objOptions.DiskFileName = strExportFile
            rpt.ExportOptions.DestinationOptions = objOptions

            rpt.SetDataSource(dt)
            rpt.Export()
            CrystalReportViewer1.ReportSource = rpt
            objOptions = Nothing
            rpt = Nothing



Is This A Good Question/Topic? 0
  • +

Replies To: adding an extension for save dialog

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: adding an extension for save dialog

Posted 21 January 2011 - 02:46 AM

i have not used reports but in file dialogs you use the filter property and addextension:
Dim FD As New OpenFileDialog
            FD.Filter = "(*.txt)|*.txt"
            FD.AddExtension = True


Was This Post Helpful? 0
  • +
  • -

#3 Vishu Sukhdev  Icon User is offline

  • D.I.C Head

Reputation: 38
  • View blog
  • Posts: 150
  • Joined: 19-February 10

Re: adding an extension for save dialog

Posted 21 January 2011 - 03:31 AM

You can also try this
        Dim ofdOpen as New OpenFileDialog
        ofdOpen.Filter = "Text Files|*.txt|All Files|*.*"
        ofdOpen.FilterIndex = 1


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1