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
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.
Hi Hans,
I've created and attached a sample project, illustrating the approach suggested in the OpenFileDialog - Set initial directory (ID:Q237765). Please review it.
Thanks,
Elliot
Elliot I am sorry no matter what I try I get this not working in my project is there not a simpeler way
Hans
Hi Hans,
Thank you for the reply.
Please check the type of the control on the form. It should have the MyRichEditControl type. Hope this helps.
Thanks,
Elliot
Elliot it is a richeditcontrol
Hans
Question if I use this in the filesave itemclick then I see a correct save path after saving then I see again a save screen can I disable this
Hans
Private Sub FileSaveItem1_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles FileSaveItem1.ItemClick
Using myFileDialog As New SaveFileDialog()
myFileDialog.InitialDirectory = reportPath()
Dim result As DialogResult = myFileDialog.ShowDialog()
End Using
End Sub
Hi Hans,
>>>>
Elliot it is a richeditcontrol
<<<<
Please change the type to the MyRichEditControl as shown in the Q237765-VB project.
>>>>
Question if I use this in the filesave itemclick then I see a correct save path after saving then I see again a save screen can I disable this
<<<<
I suggest that you create your own button on the bar and implement the desired functionality.
Thanks,
Elliot
Elliot like in your Sample I have one vb file with this code
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Namespace Document
Friend NotInheritable Class Program
''' <summary>
''' The main entry point for the application.
''' </summary>
Private Sub New()
End Sub
<STAThread()> _
Shared Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New frmDocument())
End Sub
End Class
End Namespace
This is all of the code of the form XtraBars.XtraRibbon form
Imports System.Data.SqlClient
Imports System.Configuration
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.Services
Imports DevExpress.XtraRichEdit.Services.Implementation
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.Commands
Imports DevExpress.XtraRichEdit.Services
Imports DevExpress.XtraRichEdit.Commands.Internal
Namespace Document
Partial Public Class frmDocument
Inherits Form
Public Sub New()
InitializeComponent() 'Here I got an error initialized component not declared (the designer refused to show the form)
End Sub
Public Class MyRichEditControl
Inherits RichEditControl
End Class
End Class
End Namespace
Hi Hans,
Thank you for the quick reply.
Please build the project before run the MS Studio designer. Hope this helps.
Thanks,
Elliot
Elliot,
Simple question I have my project with files in it.
So can you tell me step by step what I need to do to get this thing working like your sample at this moment the program hangs at compiling (framework error) exited with LC
Do I have to add a normal windows form or can I add a ribbon form if I choose a ribbon form do I have to add a richttextbox or?
Hans
Hi Hans,
I've created and attached a screencast, illustrating my actions.
>>>>
Do I have to add a normal windows form or can I add a ribbon form if I choose a ribbon form do I have to add a richttextbox or?
<<<<
You can use the normal or ribbon form with XtraRichEdit control. Please review the How to: Create a Simple Word Processor with Bar Menu and How to: Create a Simple Word Processor with Ribbon Menu documentation article for additional information.
Thanks,
Elliot
Eliot I followed exactly all of your steps to make a form like in the swf file the result is that my project dont work anymore see image
Hans
Hi Hans,
Thank you for providing the screen cast.
I see the problem, but I'm unable to reproduce it. It seems that this issue is specific to your application. Can you post here a small sample project that demonstrates your issue? That will make the situation clearer.
Thanks,
Elliot
<past>I suggest that you create your own button on the bar and implement the desired functionality. </Paste>
Eliot do you have a little sample how to do this (I know how to put a button on the bar) but then the code to save the file as rtf file
Regards
Hans
Hi ,
Thank you for the reply.
Here is some sample code:
.... Private Sub barButtonItem1_ItemClick(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Dim myFileDialog As New SaveFileDialog() myFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*" myFileDialog.FilterIndex = 1 myFileDialog.InitialDirectory = "C:\" myFileDialog.Title = "Save File" myFileDialog.CheckFileExists = False Dim result As DialogResult = myFileDialog.ShowDialog() If result = DialogResult.OK Then richEditControl1.SaveDocument(myFileDialog.FileName, DocumentFormat.PlainText) End If End Sub ....
Attached is a project, illustrating the suggested approach.
Thanks,
Elliot
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
Hi Hans,
Please use the RichEditControlOptions.DocumentSaveOptions property to resolve this problem. Here is some sample code:
.... 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