Change the NumbersColor at design time:
Run the application:
Workaround: move this code in the Form.Load event
The component itself seems to work fine with DPI scaling except for the search/find functionality. When you search for some text and click to go to the first instance it finds, the actual text is off-screen, though it is highlighted correctly (when you scroll down you can see it highlighted).
This is easy to replicate by changing the Windows display scale to anything other than 100%.
This is an odd one - see attached GIF.
If I attempt to select characters with the mouse (left-click + drag), at the beginning of any line of text, it won't highlight (90+% of the time). That's if I'm dragging from left-to-right.
If I select the same text from right-to-left, it works every time.
RadSyntaxEditorElement offers the following method: public CaretPosition GetPositionFromPoint(System.Drawing.Point point)
However, it doesn't return the correct CaretPosition as it requires to transform the System.Drawing.Point first:
private void MySyntaxEditor1_MouseDown(object sender, MouseEventArgs e)
{
CaretPosition pos = mySyntaxEditor1.SyntaxEditorElement.GetPositionFromPoint(GetPosition(e, mySyntaxEditor1.SyntaxEditorElement.EditorPresenter));
CaretPosition start = new CaretPosition(pos);
start.MoveToCurrentWordStart();
CaretPosition end = new CaretPosition(pos);
end.MoveToCurrentWordEnd();
mySyntaxEditor1.SyntaxEditorElement.Selection.Select(start, end);
}
public Telerik.WinControls.SyntaxEditor.UI.Point GetPosition(System.Windows.Forms.MouseEventArgs args, Telerik.WinControls.SyntaxEditor.UI.UIElement element)
{
System.Drawing.Point screenLocation = mySyntaxEditor1.SyntaxEditorElement.PointToScreen(args.Location);
System.Drawing.Point point = element.PointFromScreen(screenLocation);
Telerik.WinControls.Layouts.RadMatrix matrix = element.TotalTransform;
matrix.Invert();
return new System.Drawing.PointF(point.X * matrix.ScaleX, point.Y * matrix.ScaleY);
}
I'm trying to use the new RadSyntaxEditor in a popup editor and I'm having issues and questions. I'm using it in a component built in code that is used to edit a SQL Query from a grid cell double click. It seems to work except when I press enter to insert a new line it does not do that, instead the default form button is fired to close the form. Note that I can launch the form to either show a multi-line textbox or a RadSyntaxEditor depending on the input parameters. It works perfectly with the textbox. The issue is with the RadSyntaxEditor
I also have the following questions:
I cannot find any documentation on loading text into the RadSyntaxEditor is my code correct for this?
I cannot find any documentation regarding the Document property - where do I find that?
I cannot find anything on how to get the text out of the RadSyntaxEditor when I'm done. Is my code correct on this?
Here are my code snippets:
private void GvMrgLtr_CellDoubleClick(object sender, EventArgs e) { var m = MethodBase.GetCurrentMethod(); try { if (sender is HostedTextBoxBase sndr) sndr.Text = MemoDialog.ShowDialog(sndr.Text, "Edit", 0, false, false, true); } catch (Exception ex) { MessageBox.Show($@"{m.Name} : {ex}"); Log.Error(ex, m.Name); } }
using System.Windows.Forms; using Telerik.WinControls.UI; using Telerik.WinForms.Controls.SyntaxEditor.Taggers; using Telerik.WinForms.SyntaxEditor.Core.Text; namespace P3CMS.Components { internal static class MemoDialog { public static string ShowDialog(string text, string caption, int maxLength = 0, bool ro = false, bool spellcheck = true, bool sqlSyntaxHighlight = false) { var originalText = text; var memoDialogForm = new RadForm { Width = 500, Height = 700, FormBorderStyle = FormBorderStyle.Sizable, Text = caption, StartPosition = FormStartPosition.CenterScreen }; var textBox = new RadTextBox { Left = 50, Top = 40, Width = 400, Dock = DockStyle.Fill, Multiline = true, AcceptsReturn = true, Text = text, ScrollBars = ScrollBars.Both, MaxLength = maxLength, ReadOnly = ro }; var textDocument = new TextDocument(text); var radSyntaxEditor = new RadSyntaxEditor { Left = 50, Top = 40, Width = 400, Dock = DockStyle.Fill, Document = textDocument }; var tagger = new SqlTagger(radSyntaxEditor.SyntaxEditorElement); radSyntaxEditor.TaggersRegistry.RegisterTagger(tagger); var checker = new RadSpellChecker { AutoSpellCheckControl = textBox }; if (!spellcheck) checker.AutoSpellCheckControl = null; var bottomPanel = new RadPanel { Height = 60, Dock = DockStyle.Bottom }; var confirmation = new RadButton { Text = @"Ok", Left = 50, Width = 100, Top = 8, DialogResult = DialogResult.OK }; var cancel = new RadButton { Text = @"Cancel", Left = 200, Width = 100, Top = 8, DialogResult = DialogResult.Cancel }; confirmation.Click += (sender, e) => { memoDialogForm.Close(); }; if (sqlSyntaxHighlight) memoDialogForm.Controls.Add(radSyntaxEditor); else memoDialogForm.Controls.Add(textBox); memoDialogForm.Controls.Add(bottomPanel); bottomPanel.Controls.Add(confirmation); bottomPanel.Controls.Add(cancel); memoDialogForm.AcceptButton = confirmation; memoDialogForm.CancelButton = cancel; if (!sqlSyntaxHighlight) textBox.Select(0, 0); return memoDialogForm.ShowDialog() == DialogResult.OK ? sqlSyntaxHighlight ? textDocument.CurrentSnapshot.GetText() : textBox.Text : originalText; } } }
RadSyntaxEditor allows the end-users to select a part of the text and drag the selection to a new position.
Currently, there is no public API that allows you to control whether the drag operation should start, on what target line you are dragging over (and whether you can drop on it) and when you drop the selection.
XMLFoldingTagger is not documented. Neither here: https://docs.telerik.com/devtools/winforms/controls/syntax-editor/features/taggers/overview nor here: https://docs.telerik.com/devtools/winforms/controls/syntax-editor/features/taggers/folding-taggers.
Setting the SyntaxEditorElement.IsReadOnly property to true disables editing the text inside RadSyntaxEditor. However, when opening the Find and Replace dialog, the user is still allowed to replace the text and thus change the content in the document. This shouldn't be allowed when the control is in read-only mode.
Workaround:
this.radSyntaxEditor1.SyntaxEditorElement.InputHandler = new MyInputBehavior(this.radSyntaxEditor1.SyntaxEditorElement); public class MyInputBehavior : SyntaxEditorInputBehavior { public MyInputBehavior(RadSyntaxEditorElement editor) : base(editor) { } protected override void PerformOpenFileDialog(KeyEventArgs e) { this.SyntaxEditor.SearchPanel.ReplaceAllButton.Enabled = false; this.SyntaxEditor.SearchPanel.ReplaceButton.Enabled = false; this.SyntaxEditor.SearchPanel.ReplaceTextBox.Enabled = false; base.PerformOpenFileDialog(e); } }
When I setup and OverloadList, the OverloadListWindow follows the cursor and can move off screen so the user can't see/read the information that is presented.
Workaround: adjust the position of the overload window when it is shown:
this.radSyntaxEditor1.SyntaxEditorElement.IntelliPrompts.OverloadListWindow.VisibleChanged+=OverloadListWindow_VisibleChanged;
private void OverloadListWindow_VisibleChanged(object sender, EventArgs e)
{
ShapedForm f = sender as ShapedForm;
Screen myScreen = Screen.FromControl(this);
Rectangle area = myScreen.WorkingArea;
if (f.Left + f.Width > area.Width)
{
f.Left = area.Width - f.Width -5;
}
}
If my xml string contains an element with attributes, XMLFoldingTagger just ignores it!
For example:
<Formular DebugMode="F" Version="1" Typ="Rechnung">
<OtherElements/>
<Formular/>
is ignored. Element Formular is not recognized by the XMLFoldingTagger. Only simple elements are recognized, like:
<Formular>
<OtherElements/>
<Formular/>
Please refer to the attached gif file.
Workaround: set bottom padding by setting the SyntaxEditorElement.HorizontalScrollBar.Padding property.
mySyntaxEditor1.SyntaxEditorElement.HorizontalScrollBar.Padding = new Padding(0, 0, 0, 2);