)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to implement the SelectionMargin feature in WinForms SyntaxEditor (EditControl)?

Platform: WinForms |
Control: EditControl |
Published Date: April 30, 2011 |
Last Revised Date: December 13, 2019

Selection margin feature

This feature helps the user in setting the SelectionMargin's BackColor, FrontColor and the Width of the margin, which helps to create a more user-friendly environment. Please refer the below code, to know more about it.

C#

private void Width_menuItem_Click(object sender, System.EventArgs e)
{
    MenuItem item = sender as MenuItem;
    if (item.Text == "25")
       this.editControl1.SelectionMarginWidth = 25;
    else if (item.Text == "50")
       this.editControl1.SelectionMarginWidth = 50;
    else if (item.Text == "75")
       this.editControl1.SelectionMarginWidth = 75;
    else if (item.Text == "100")
       this.editControl1.SelectionMarginWidth = 100;
    else if (item.Text == "125")
       this.editControl1.SelectionMarginWidth = 125;
}
private void BackgroundColor_menuItem_Click(object sender, System.EventArgs e)
{
    MenuItem item = sender as MenuItem;
    if (item.Text == "LightBlue")
       this.editControl1.SelectionMarginBackgroundColor = Color.LightBlue;
    else if (item.Text == "IndianRed")
       this.editControl1.SelectionMarginBackgroundColor = Color.IndianRed;
    else if (item.Text == "Beige")
       this.editControl1.SelectionMarginBackgroundColor = Color.Beige;
}
private void ForegroundColor_menuItem_Click(object sender, System.EventArgs e)
{
    MenuItem item = sender as MenuItem;
    if (item.Text == "Gray")
       this.editControl1.SelectionMarginForegroundColor = Color.Gray;
    else if (item.Text == "Maroon")
       this.editControl1.SelectionMarginForegroundColor = Color.Maroon;
    else if (item.Text == "Navy")
       this.editControl1.SelectionMarginForegroundColor = Color.Navy;
}

 

VB

Private Sub Width_menuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim item As MenuItem = TryCast(sender, MenuItem)
    If item.Text = "25" Then
       Me.editControl1.SelectionMarginWidth = 25
    ElseIf item.Text = "50" Then
       Me.editControl1.SelectionMarginWidth = 50
    ElseIf item.Text = "75" Then
       Me.editControl1.SelectionMarginWidth = 75
    ElseIf item.Text = "100" Then
       Me.editControl1.SelectionMarginWidth = 100
    ElseIf item.Text = "125" Then
       Me.editControl1.SelectionMarginWidth = 125
    End If
End Sub 'Width_menuItem_Click
Private Sub BackgroundColor_menuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim item As MenuItem = TryCast(sender, MenuItem)
    If item.Text = "LightBlue" Then
       Me.editControl1.SelectionMarginBackgroundColor = Color.LightBlue
    ElseIf item.Text = "IndianRed" Then
       Me.editControl1.SelectionMarginBackgroundColor = Color.IndianRed
    ElseIf item.Text = "Beige" Then
       Me.editControl1.SelectionMarginBackgroundColor = Color.Beige
    End If
End Sub 'BackgroundColor_menuItem_Click
Private Sub ForegroundColor_menuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim item As MenuItem = TryCast(sender, MenuItem)
    If item.Text = "Gray" Then
       Me.editControl1.SelectionMarginForegroundColor = Color.Gray
    ElseIf item.Text = "Maroon" Then
       Me.editControl1.SelectionMarginForegroundColor = Color.Maroon
    ElseIf item.Text = "Navy" Then
       Me.editControl1.SelectionMarginForegroundColor = Color.Navy
    End If
End Sub 'ForegroundColor_menuItem_Click

 

Reference link: https://help.syncfusion.com/windowsforms/syntaxeditor/appearance#selection-margin

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon