Hello Community,
I was wondering if its possible to make an editor like Notepad++ (I'm talking about the text area).
So it will change the colour of the words (funtions and commands) also with the margin with the numbers and the code folding.

Please help with what you can even if you can give me bits and peices to make the script myself.

Thanks

if its possible to make an editor like Notepad++

Certainly it is. But why do you want to reinvent the wheel when there are editors out there that will do this already?

Please help with what you can even if you can give me bits and peices to make the script myself.

We are not going to write it for you. That's not what this forum is for. However, if you make an attempt to write it yourself we can help you out with the problem areas. It might help to know your level of expertise.

I'm not trying to reinvent the wheel (remake notepad++) i just want to know how to make a margin with the numbers and code folding but i found out how to make a margin numbers.

I found this code and fixed it to the way i want it but i want the user able to choose there own colours for the functions but it don't. I choose the colour from the properties (eg. i'll choose red) but it won't change in the syntaxRTB in the form it stays black the only time it will change is if i change the color in the private _SyntaxHighlight_COLOUR(what ever number)

Public Class SyntaxRTB
    Inherits System.Windows.Forms.RichTextBox
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    Private Declare Function LockWindowUpdate Lib "user32" (ByVal hWnd As Integer) As Integer
    Private Words As New DataTable
    Private _SyntaxHighlight_COLOUR1 As Color = Color.Black
    Private _SyntaxHighlight_COLOUR2 As Color = Color.Black
    Private _SyntaxHighlight_COLOUR3 As Color = Color.Black
    Private _SyntaxHighlight_COLOUR4 As Color = Color.Black
    Private _SyntaxHighlight_COLOUR5 As Color = Color.Black
    Private _SyntaxHighlight_COLOUR6 As Color = Color.Black
    Private _SyntaxHighlight_COLOUR7 As Color = Color.Black

    'Contains Windows Messages for the SendMessage API call
    Private Enum EditMessages
        LineIndex = 187
        LineFromChar = 201
        GetFirstVisibleLine = 206
        CharFromPos = 215
        PosFromChar = 1062
    End Enum

    Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
        ColorVisibleLines()
        Main.IsSaved.Checked = False
        Try
            Main.ToolStripStatusLabel2.Text = Len(Me.Text)
        Catch ex As Exception
        End Try
    End Sub

    Public Sub ColorRtb()
        Dim FirstVisibleChar As Integer
        Dim i As Integer = 0

        While i < Me.Lines.Length
            FirstVisibleChar = GetCharFromLineIndex(i)
            ColorLineNumber(i, FirstVisibleChar)
            i += 1
        End While
    End Sub

    Public Sub ColorVisibleLines()
        Dim FirstLine As Integer = FirstVisibleLine()
        Dim LastLine As Integer = LastVisibleLine()
        Dim FirstVisibleChar As Integer

        If (FirstLine = 0) And (LastLine = 0) Then
            'If there is no text it will error, so exit the sub
            Exit Sub
        Else
            While FirstLine < LastLine
                FirstVisibleChar = GetCharFromLineIndex(FirstLine)
                ColorLineNumber(FirstLine, FirstVisibleChar)
                FirstLine += 1
            End While
        End If

    End Sub

    Public Sub ColorLineNumber(ByVal LineIndex As Integer, ByVal lStart As Integer)
        Dim i As Integer = 0
        Dim Instance As Integer
        Dim LeadingChar, TrailingChar As String
        Dim SelectionAt As Integer = Me.SelectionStart
        Dim MyRow As DataRow
        Dim Line() As String, MyI As Integer, MyStr As String

        ' Lock the update
        LockWindowUpdate(Me.Handle.ToInt32)

        MyI = lStart

        Line = Split(Me.Lines(LineIndex).ToLower, " ")

        For Each MyStr In Line
            Me.SelectionStart = MyI
            Me.SelectionLength = MyStr.Length

            If Words.Rows.Contains(MyStr) Then
                MyRow = Words.Rows.Find(MyStr)
                Me.SelectionColor = Color.FromName(MyRow("Color"))
            Else
                Me.SelectionColor = Color.Black
            End If

            MyI += MyStr.Length + 1
        Next

        ' Restore the selectionstart
        Me.SelectionStart = SelectionAt
        Me.SelectionLength = 0
        Me.SelectionColor = Color.Black

        ' Unlock the update
        LockWindowUpdate(0)
    End Sub

    Public Function GetCharFromLineIndex(ByVal LineIndex As Integer) As Integer
        Return SendMessage(Me.Handle, EditMessages.LineIndex, LineIndex, 0)
    End Function

    Public Function FirstVisibleLine() As Integer
        Return SendMessage(Me.Handle, EditMessages.GetFirstVisibleLine, 0, 0)
    End Function

    Public Function LastVisibleLine() As Integer
        Dim LastLine As Integer = FirstVisibleLine() + (Me.Height / Me.Font.Height)

        If LastLine > Me.Lines.Length Or LastLine = 0 Then
            LastLine = Me.Lines.Length
        End If

        Return LastLine
    End Function

    Public Sub New()
        Dim MyRow As DataRow
        Dim arrKeyWords() As String, strKW As String

        'Load all the keywords and the colors to make them 
        Words.Columns.Add("Word")
        Words.PrimaryKey = New DataColumn() {Words.Columns(0)}
        Words.Columns.Add("Color")

        arrKeyWords = New String() {"select", "insert", "delete", _
           "truncate", "from", "where", "into", "inner", "update", _
           "outer", "on", "is", "declare", "set", "use", "values", "as", _
           "order", "by", "drop", "view", "go", "trigger", "cube", _
           "binary", "varbinary", "image", "char", "varchar", "text", _
           "datetime", "smalldatetime", "decimal", "numeric", "float", _
           "real", "bigint", "int", "smallint", "tinyint", "money", _
           "smallmoney", "bit", "cursor", "timestamp", "uniqueidentifier", _
           "sql_variant", "table", "nchar", "nvarchar", "ntext", "left", _
           "right", "like", "and", "all", "in", "null", "join", "not", "or"}

        For Each strKW In arrKeyWords
            MyRow = Words.NewRow()
            MyRow("Word") = strKW
            MyRow("Color") = COLOUR1.Name
            Words.Rows.Add(MyRow)
        Next
    End Sub

    Public Property COLOUR1() As Color
        Get
            Return _SyntaxHighlight_COLOUR1
        End Get
        Set(ByVal Value As Color)
            _SyntaxHighlight_COLOUR1 = Value
        End Set
    End Property

    Public Property COLOUR2() As Color
        Get
            Return _SyntaxHighlight_COLOUR2
        End Get
        Set(ByVal Value As Color)
            _SyntaxHighlight_COLOUR2 = Value
        End Set
    End Property

    Public Property COLOUR3() As Color
        Get
            Return _SyntaxHighlight_COLOUR3
        End Get
        Set(ByVal Value As Color)
            _SyntaxHighlight_COLOUR3 = Value
        End Set
    End Property

    Public Property COLOUR4() As Color
        Get
            Return _SyntaxHighlight_COLOUR4
        End Get
        Set(ByVal Value As Color)
            _SyntaxHighlight_COLOUR4 = Value
        End Set
    End Property

    Public Property COLOUR5() As Color
        Get
            Return _SyntaxHighlight_COLOUR5
        End Get
        Set(ByVal Value As Color)
            _SyntaxHighlight_COLOUR5 = Value
        End Set
    End Property

    Public Property COLOUR6() As Color
        Get
            Return _SyntaxHighlight_COLOUR6
        End Get
        Set(ByVal Value As Color)
            _SyntaxHighlight_COLOUR6 = Value
        End Set
    End Property

    Public Property COLOUR7() As Color
        Get
            Return _SyntaxHighlight_COLOUR7
        End Get
        Set(ByVal Value As Color)
            _SyntaxHighlight_COLOUR7 = Value
        End Set
    End Property
End Class

Please help i'm really good with visual basic.net but ive never worked with something like this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.