I am needing that every document (text file) is converted to the same Font(Consolas) and Size(10).
I have tried
Public
Sub
SetDefaultFontPropertiesToEditor(
ByVal
editor
As
RadRichTextEditor)
editor.RichTextBoxElement.ChangeFontFamily(
New
Telerik.WinControls.RichTextEditor.UI.FontFamily(
"Consolas"
))
editor.RichTextBoxElement.ChangeFontSize(Unit.PointToDip(10))
editor.DocumentInheritsDefaultStyleSettings =
True
End
Sub
Which changes the Font and Size drop downs but not the document.
any thoughts
37 Answers, 1 is accepted
I got it figured out.
Dim
editor
As
New
RadDocumentEditor(document)
document.Selection.SelectAll()
editor.ChangeFontSize(10)
editor.ChangeFontFamily(
New
Telerik.WinControls.RichTextEditor.UI.FontFamily(
"Consolas"
))
Dim
marg
As
New
Telerik.WinForms.Documents.Layout.Padding(25, 25, 25, 25)
editor.ChangeSectionActualPageMargin(marg)
Your solution is correct. If the document already has content you should select it first.
Please let me know if there is something else I can help you with.
Dimitar
Telerik
if I add text to the document, how do I change the color of the added font.
I am trying
Dim
documentEditor
As
New
RadDocumentEditor(
Me
.RadRichTextEditor1.Document)
documentEditor.ChangeForeColor(Color.Red)
documentEditor.Insert (str)
Thank you for writing back.
Your approach is correct, but you should set the color like this:
Dim
documentEditor
As
New
RadDocumentEditor(
Me
.radRichTextEditor1.Document)
documentEditor.ChangeForeColor(Telerik.WinControls.RichTextEditor.UI.Colors.Red)
documentEditor.Insert(
"test"
)
Let me know if you have additional questions.
Dimitar
Telerik
Thank you for writing back.
You can insert a span instead of just text fragment:
Dim
documentEditor
As
New
RadDocumentEditor(
Me
.radRichTextEditor1.Document)
Dim
span
As
New
Span(
"Span declared in code-behind"
)
span.ForeColor = Colors.Red
documentEditor.InsertInline(span)
Please let me know if there is something else I can help you with.
Dimitar
Telerik
Funny you should ask. I just did this on my side.
Dim
editor
As
New
RadDocumentEditor(document)
document.Selection.SelectAll()
editor.ChangeFontSize(10)
editor.ChangeFontFamily(
New
Telerik.WinControls.RichTextEditor.UI.FontFamily(
"Consolas"
))
Dim
marg
As
New
Telerik.WinForms.Documents.Layout.Padding(15, 15, 15, 15)
editor.ChangeSectionActualPageMargin(marg)
editor.ChangeParagraphSpacingAfter(0.0)
editor.ChangeParagraphSpacingBefore(0.0)
I am using a function to create the RadDocument, hope this helps
private
void
BatchProof_Load(
object
sender, EventArgs e)
{
RadRichTextEditor1.Document = ImportFile(_ContractRef);
}
public
RadDocument ImportFile(
string
contract)
{
RadDocument document =
null
;
IDocumentFormatProvider provider =
new
TxtFormatProvider();
using
(IO.Stream stream = IO.File.Open(
"your file your reading"
, IO.FileMode.Open)) {
document = provider.Import(stream);
}
RadDocumentEditor editor =
new
RadDocumentEditor(document);
document.Selection.SelectAll();
editor.ChangeFontSize(10);
editor.ChangeFontFamily(
new
Telerik.WinControls.RichTextEditor.UI.FontFamily(
"Consolas"
));
Telerik.WinForms.Documents.Layout.Padding marg =
new
Telerik.WinForms.Documents.Layout.Padding(15, 15, 15, 15);
editor.ChangeSectionActualPageMargin(marg);
editor.ChangeParagraphSpacingAfter(0.0);
editor.ChangeParagraphSpacingBefore(0.0);
RadRichTextEditor1.CurrentEditingStyle.SetPropertyValue(Span.ForeColorProperty, Colors.Red);
return
document;
}
sorry sir
plz find attach
what is the parameter importfile ?
Use This
private
void
BatchProof_Load(
object
sender, EventArgs e)
{
RadRichTextEditor1.Document = ImportFile();
}
public
RadDocument ImportFile()
{
RadDocument document =
null
;
IDocumentFormatProvider provider =
new
TxtFormatProvider();
using
(IO.Stream stream = IO.File.Open(
"c:\\123.doc"
, IO.FileMode.Open)) {
document = provider.Import(stream);
}
RadDocumentEditor editor =
new
RadDocumentEditor(document);
document.Selection.SelectAll();
editor.ChangeFontSize(10);
editor.ChangeFontFamily(
new
Telerik.WinControls.RichTextEditor.UI.FontFamily(
"Consolas"
));
Telerik.WinForms.Documents.Layout.Padding marg =
new
Telerik.WinForms.Documents.Layout.Padding(15, 15, 15, 15);
editor.ChangeSectionActualPageMargin(marg);
editor.ChangeParagraphSpacingAfter(0.0);
editor.ChangeParagraphSpacingBefore(0.0);
RadRichTextEditor1.CurrentEditingStyle.SetPropertyValue(Span.ForeColorProperty, Colors.Red);
return
document;
}
If you are working on windows 7 or higher, the root drive ("C:\") is not a great place to access files from as the security is set real high.
I suggest using "C:\Temp\123.docx" and make sure you can read and write to that folder
see i am custom the code put when run see attache
-----------------code
public RadDocument ImportFile()
{
RadDocument document = null;
IDocumentFormatProvider provider = new TxtFormatProvider();
//
System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
openDialog.Filter = "Documents|*.docx";
openDialog.Multiselect = false;
DialogResult dialogResult = openDialog.ShowDialog();
//
if (dialogResult == System.Windows.Forms.DialogResult.OK)
{
using (Stream stream = openDialog.OpenFile())
{
document = provider.Import(stream);
}
}
//using (System.IO.Stream stream = System.IO.File.Open("c:\\123.docx", System.IO.FileMode.Open))
//{
// document = provider.Import(stream);
//}
RadDocumentEditor editor = new RadDocumentEditor(document);
document.Selection.SelectAll();
editor.ChangeFontSize(10);
editor.ChangeFontFamily(new Telerik.WinControls.RichTextEditor.UI.FontFamily("Consolas"));
Telerik.WinForms.Documents.Layout.Padding marg = new Telerik.WinForms.Documents.Layout.Padding(15, 15, 15, 15);
editor.ChangeSectionActualPageMargin(marg);
editor.ChangeParagraphSpacingAfter(0.0);
editor.ChangeParagraphSpacingBefore(0.0);
radRichTextEditor1.CurrentEditingStyle.SetPropertyValue(Span.ForeColorProperty, Colors.Red);
return document;
}​
hello
when use font name " Al-mohanad" in radrichtexteditor" cannot and showing the words
plz find attached
hello
how remove data or clear radRichTextEditor1 in c#
Thank you for writing.
@Mahmoud
I am sending you attached a sample project in which I am importing a .docx file into RadRichTextEditor. Basically, I have followed the example as demonstrated here: Import/Export. You should also make sure that the file you are trying to read is available, not locked and you have the required permissions to access it. In my project, I have also demonstrated how the content can be cleared and how the spacing can be decreased. For detailed information and examples of the available features in RadRichTextEditor please refer to the following section of our documentation: Features.
Considering your request, regarding the Al- font, please check the following forum thread as the same matter has also been discussed there: http://www.telerik.com/forums/changing-copied-arabic-text-font-in-document-richtexteditor.
My example is in C#, in case you need conversion between VB and C# and vice versa, please note that we have a free online tool available here: http://converter.telerik.com/.
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Where is RadDocumentEditor class? I can't find it.
And I don't want to RadDocumentEditor class. I just want to change default value of RadRichTextEdtitor.
How to do it?
Inspite of change font property of RadRichTextEditor, font is not change font is like below
Font
Font Family: Verdana -> Want to change Arial
Font Style: Normal
Font Weight: Normal
Font Size: 12 -> Want to change 10
Paragraph
Spacing After: 12
Line Spacing: 1.15 -> Want to change 0.5
Style
Type: Default
Thank you for writing.
RadDocumentEditor class is part of the Telerik.WinForms.Documents.Model namespace and is located in the Telerik.WinControls.RichTextEditor.dll assembly.
Considering your task, you can achieve it the following way:
private
void
SetDefaultFontPropertiesToEditor(RadRichTextEditor editor)
{
editor.Document.Selection.SelectAll();
editor.RichTextBoxElement.ChangeFontFamily(
new
Telerik.WinControls.RichTextEditor.UI.FontFamily(
"Arial"
));
editor.RichTextBoxElement.ChangeFontSize(Unit.PointToDip(10));
editor.RichTextBoxElement.ChangeFontStyle(Telerik.WinControls.RichTextEditor.UI.FontStyles.Normal);
editor.RichTextBoxElement.ChangeFontWeight(Telerik.WinControls.RichTextEditor.UI.FontWeights.Normal);
editor.RichTextBoxElement.ChangeParagraphLineSpacingType(LineSpacingType.Auto);
editor.RichTextBoxElement.ChangeParagraphLineSpacing(0.5);
editor.RichTextBoxElement.ChangeParagraphSpacingAfter(12);
editor.DocumentInheritsDefaultStyleSettings =
true
;
}
Please, also check the following documentation resources providing detailed information on how RadRichTextEditor is functioning: Getting Started, FAQ, Document Elements, Features.
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
After I had call the function which you give on Form Loading event handler, I input text. But font is not changed.
Should I call the function whenever inputting text?
I hope that I set font at first time, and it kept by I change to another font.
Thank you for writing back.
If you would like to change the font styling of the document, you need to make sure that the document you are importing is actually loaded. For the purpose, you can subscribe to the DocumentChanged event.
In case you are working with an empty document and you call the method I last sent you in the Load event of the form, this should apply the settings and the new text you enter should be with the newly applied style.
I am sending you attached my sample project as well as a gif file showing the result on my end. If you are still experiencing issues please send me a code snippet demonstrating your local setup.
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Hello
I have Problem in raddock ,documentContainer
i need change color cannot changed in c# winforms
Thank you for writing.
This thread discusses setting fonts and changing sizes in RadRichTextEditor. We try to keep the forum threads and support tickets strictly focused on one topic. This way it is easier for us and also for the whole community to search for a solution of a scenario.
Please open up a new forum thread or support ticket specifying RadDock as your product. In the meantime, you can check our online documentation: RadDock.
Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Hi guys
i have question about telerik radrichedit;
how we can set default paper size as A4 or A5 in code???
Thank you for writing.
The following snippet shows how you can change the page size:
radRichTextEditor1.Document.LayoutMode = DocumentLayoutMode.Paged;
radRichTextEditor1.ChangeSectionPageSize(PaperTypeConverter.ToSize(PaperTypes.A5));
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Telerik by Progress
Dear Dimitar,
thanks a million,,,
ost
Hello guys
I've used above code for setting the page size and it s work but after this below code
radRichTextEditor1.Document=doc;
all the setting dont work
it means that when the text are entered in Radrichtext all of setting dont work
would you mind help me how i can fix it
If you assigning new document you need to change the settings again. Each document has is own PageSize.
I hope this information is useful.
Regards,
Dimitar
Telerik by Progress
I've used Radrichtexteditor in my project. In addition, I've used richtexteditorribbonbar and it is associated to radrichtexteditor.
In my project I get information from user through radRichTextEditor1 and convert context to Html for save in database (of course for this reason i used ImportHTML and exporttoHTML function ), my problem is : during execution , sometimes I face in this error ;
"{The function evaluation was disabled because of an out of memory exception.}"
I checked it and I figure out after each 10 times that user open the form contains of radrichtexteditor+richtexteditorribbonbar , this error is appeared.
How can I solve this problem?
I've attached the pic of error too, thanks a million for guiding me.
I have another problem too about opening the form which contain radrichtexteditor+richtexteditorribbonbar , it takes to much time to open and it is no acceptable for user, what can I do to improve the time ?
If this form has many controls it, creating a new instance can be delayed a little bit. In this case, you can create a single instance and then just show/hide the form when it is needed. This will reduce the memory footprint as well.
In addition, I have noticed that you have opened a new thread for this and we can continue to discuss this matter there. In general, there can be many reasons for the memory leak (a reference to another object, subscription to an event). The following article shows what you need to check in order to resolve this: Things to keep in mind when inspecting your application's memory usage.
I hope this information is useful.
Regards,
Dimitar
Telerik by Progress
Hello,
This topic is driving me mad!! I have been trying to get a default font and size for the RadTextBoxEditor for 3 days. I tried each and every piece of code that is described below but until now not with the desired result.
I know this is already an old topic, and it seems to be solved since the last post was of 2015, but I don't get the control to behave as I want.
I need the RichTextBoxEditor because of the MailMerge possibilities, but I don't want the user to change font size, type, colors or nothing, as the output will be a text file.
Due to company rules, I need a default font and size in the application.
To be short: I want the control to behave as a normal textbox, except for the mailmerge fields.
Scenario 1:
Set the default font family and size.
I load a document from Xaml with the XamlFormatProvider, OK.
I select the entire document, change the font family and font size. OK.
Now the user starts to type after the loaded text: to my horror font size 12 and original family again....
Scenario 2:
I don't load any document. Set the default font family and size.
The user starts to type, OK.
The user reconsiders, types Ctrl-A, Delete, starts typing again -> back to font size 12 and original family again...
I'm using version 2017 Q1...
What am I overlooking?
In order the font to remain when the entire content is deleted, you need to change the "Normal" style. This should be done for each imported or new document as well:
StyleDefinition h1 = editor.Document.StyleRepository.GetValueOrNull(
"Normal"
);
h1.SpanProperties.FontSize = Unit.PointToDip(8.5);
h1.SpanProperties.FontWeight = Telerik.WinControls.RichTextEditor.UI.FontWeights.Normal;
h1.SpanProperties.FontFamily =
new
Telerik.WinControls.RichTextEditor.UI.FontFamily(
"Consolas"
);
I hope this will be useful.
Regards,
Dimitar
Progress Telerik
Finally the solution I was looking for.
Thanks a million!