hi you guys changed my issue question into a suggestion without providing any help at all!! re Q237215. I need to know how to bypass the default functionality of the ribbon control open dialog so I can set the intial directory, I would have thought this was straight forward as it is easy to do with an open file dialog and makes no sense at all to be undoable.
Dim myFileDialog As OpenFileDialog = New OpenFileDialog()
With myFileDialog
.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
.FilterIndex = 1
.InitialDirectory = "C:"
.Title = "Open File"
.CheckFileExists = False
End With
We have closed this ticket because another page addresses its subject:
Add the capability to customize OpenFileDialog and SaveFileDialog settings (or replace these dialogs) in a corresponding RichEditControl's event handlerOpenFileDialog - Set initial directory
Answers approved by DevExpress Support
Hi Chris,
There is a simple way to resolve this problem. You should create your own class based on the XtraRichEdit control and override the LoadDocument method. Here is some sample code:
Visual Basic ....
Public Class MyRichEditControl
Inherits RichEditControl
Public Sub New()
MyBase.New()
End Sub
Public Overrides Sub LoadDocument()
Using myFileDialog As New OpenFileDialog()
myFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
myFileDialog.FilterIndex = 1
myFileDialog.InitialDirectory = "C:\"
myFileDialog.Title = "Open File"
myFileDialog.CheckFileExists = False
Dim result As DialogResult = myFileDialog.ShowDialog()
If result = DialogResult.OK Then
Me.LoadDocument(myFileDialog.FileName, DocumentFormat.PlainText)
End If
End Using
'base.LoadDocument();
End Sub
....
In addition, you can use this approach to customize the File save dialog. Here is some sample code:
Visual Basic ....
Public Class MyRichEditControl
Inherits RichEditControl
Public Sub New()
MyBase.New()
End Sub
Public Overrides Sub SaveDocument()
Using myFileDialog As New SaveFileDialog()
myFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
myFileDialog.FilterIndex = 1
myFileDialog.InitialDirectory = "C:\"
myFileDialog.CheckFileExists = False
Dim result As DialogResult = myFileDialog.ShowDialog()
If result = DialogResult.OK Then
Me.SaveDocument(myFileDialog.FileName, DocumentFormat.PlainText)
End If
End Using
End Sub
Public Overrides Sub SaveDocumentAs()
SaveDocument()
End Sub
End Class
....
Try this solution, and let us know whether it helps.
Thanks,
Elliot
Updated by Yulia
The code implemented in the overridden RichEditControl.LoadDocument method is executed when the RichEditControl.LoadDocument method is called in code behind. This code does not affect the "Open document" RichEditControl's command that can be invoked from the RichEditControl Ribbon or by pressing the "Ctrl+O" shortcut. To change the behavior of the built-in RichEditControl's command, it is necessary to substitute the default command with a custom one.
This approach is demonstrated in the How to replace standard XtraRichEdit command with your own custom command Code Example. The RichEditControl exposes the IRichEditCommandFactoryService interface that enables you to substitute the default command with your own custom command. First, create a command class inherited from the XtraRichEdit.Commands.LoadDocumentCommand command. Then, override the ExecuteCore method to call the "OpenFileDialog" with the predefined settings.
As for saving the document, you can customize a default path to the output document used in the "SaveFileDialog" via the DocumentSaveOptions.CurrentFileName property.
Sorry, is this no more working ?
I receive a MissingManifestRessourceException. If it should still work, please provide a small vb sample.
BTW, savedocument seems to be changed, too
Hello Chris,
The code implemented in the overridden RichEditControl.LoadDocument method is executed when the RichEditControl.LoadDocument method is called in code behind. This code does not affect the "Open document" RichEditControl's command that can be invoked from the RichEditControl Ribbon or by pressing the "Ctrl+O" shortcut. To change the behavior of the built-in RichEditControl's command, it is necessary to substitute the default command with a custom one.
This approach is demonstrated in the How to replace standard XtraRichEdit command with your own custom command Code Example. The RichEditControl exposes the IRichEditCommandFactoryService interface that enables you to substitute the default command with your own custom command. First, create a command class inherited from the XtraRichEdit.Commands.LoadDocumentCommand command. Then, override the ExecuteCore method to call the "OpenFileDialog" with the predefined settings.
As for saving the document, you can customize a default path to the output document used in the "SaveFileDialog" via the DocumentSaveOptions.CurrentFileName property.
Should you have any questions or concerns while implementing this approach, let me know.
I have updated our previous answer with this solution.
>>I receive a MissingManifestRessourceException.<<
I could not replicate this exception on my side. I recommend you review the What does MissingManifestResourceException mean and how to fix it? article where this issue is described in detail. I hope the information provided there will help you overcome the problem.