Ticket Q254195
Visible to All Users

open file dialog

created 15 years ago

I know there is a subject http://www.devexpress.com/issue=Q237765 this is what I want, but I do not know how to use this in my project
I have a xtrabars.xtraRibbon.Ribbon form below all the code, I do not know how to make an extra class like in the sample
Hans
Public Class frmDocument
    Private Sub frmDocument_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If FileSaveItem1.Enabled = True Then
            Dim Antwoord As String = MsgBox("Wilt u de wijzigingen bewaren?", MsgBoxStyle.YesNoCancel)
            Select Case Antwoord
                Case vbYes
                    FileSaveItem1.PerformClick()
                    e.Cancel = True
                Case vbNo
                Case vbCancel
                    e.Cancel = True
            End Select
        End If
    End Sub
    Private Sub CursorPosition()
        Dim str As String = String.Format("CP: {0}", txtDocument.Document.CaretPosition.ToInt())
        Me.BarStaticItem1.Caption = str
    End Sub
    Private Sub txtDocument_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDocument.Click
        CursorPosition()
    End Sub
    Private Sub txtDocument_ContentChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDocument.ContentChanged
        CursorPosition()
    End Sub
End Class

Show previous comments (14)

    Elliot thanks the saving works like I want I made this of it, one problem if I open a file and type some text then push the save butten, the dialog screen pops up normaly this won't happen't, if the file exist.
    Hans
       Dim myFileDialog As New SaveFileDialog()
            myFileDialog.Filter = "Rich Text Format (*.rtf)|*.rtf|Text Files (*.txt)|*.txt|Hyper Text Markup Language Format(*.htm: *.html)|*.htm|Web Archive, Single File(*.mht)|*.mht|Word2007 Document (*.docx)|*.docx|Open Document Text Document (*.odt)|*.odt|XML Document (*.xml)|*.xml|All files (*.*)|*.*)"
            myFileDialog.InitialDirectory = "c:"
            myFileDialog.Title = "Bestand bewaren"
            myFileDialog.CheckFileExists = False
            Dim result As DialogResult = myFileDialog.ShowDialog()
            If result = System.Windows.Forms.DialogResult.OK Then
                Select Case myFileDialog.FilterIndex
                    Case 1
                        RichEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.Rtf)
                    Case 2
                        RichEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.PlainText)
                    Case 3
                        RichEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.Html)
                    Case 4
                        RichEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.Mht)
                    Case 5
                        RichEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.OpenXml)
                    Case 6
                        RichEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.OpenDocument)
                    Case 7
                        RichEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.WordML)
                End Select
            End If

    DevExpress Support Team 15 years ago

      Hi Hans,
      Please use the RichEditControlOptions.DocumentSaveOptions property to resolve this problem. Here is some sample code:

      Visual Basic
      .... Private Sub barButtonItem1_ItemClick(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barButtonItem1.ItemClick Dim opts As DocumentSaveOptions = richEditControl1.Options.DocumentSaveOptions If opts.CurrentFileName <> String.Empty Then richEditControl1.SaveDocument(opts.CurrentFileName, opts.CurrentFormat) Return End If Dim myFileDialog As New SaveFileDialog() myFileDialog.Filter = "Rich Text Format (*.rtf)|*.rtf|Text Files (*.txt)|*.txt|Hyper Text Markup Language Format(*.htm: *.html)|*.htm|Web Archive, Single File(*.mht)|*.mht|Word2007 Document (*.docx)|*.docx|Open Document Text Document (*.odt)|*.odt|XML Document (*.xml)|*.xml|All files (*.*)|*.*)" myFileDialog.InitialDirectory = "c:\" myFileDialog.Title = "Bestand bewaren" myFileDialog.CheckFileExists = False Dim result As DialogResult = myFileDialog.ShowDialog() If result = System.Windows.Forms.DialogResult.OK Then Select Case myFileDialog.FilterIndex Case 1 richEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.Rtf) Case 2 richEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.PlainText) Case 3 richEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.Html) Case 4 richEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.Mht) Case 5 richEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.OpenXml) Case 6 richEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.OpenDocument) Case 7 richEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.WordML) End Select End If End Sub ....

      Hope this helps.
      Thanks,
      Elliot

        Elliot thanks that works

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.