Imports system.componentmodel
Public Class MyrichtextBox
Inherits System.Windows.Forms.richtextBox
#Region "Windows Form Designer Generated Code"
Public Sub New ()
Mybase.new ()
'This call is required for the Windows Form Designer.
InitializeComponent ()
'Add any initialization after INITIALIZECOMPONENT ()
Me.Text = ""
End Sub
'UserControl overrides Dispose to clean the component list.
Protected Overloads Overrides Sub Dispose (Byval Disposing as Boolean)
IF Disposing then
IF not (Components Is Nothing) THEN
Components.dispose ()
END IF
END IF
Mybase.dispose (Disposing)
End Sub
'Windows Form Designer
Private Components as System.comPonentModel.icontainer
'Note: The following process is necessary for the Windows Form Designer.
'You can modify this process using the Windows Form Designer.
'Don't modify it using the code editor.
Components = new system.componentmodel.container ()
End Sub
#End region
Private row as integer 'line number
PRIVATE ROW_LENGTH AS INTEGER 'The maximum number of inputs per line
Public property set_num () AS Integer
Get
Return Row_Length
END GET
Set (ByVal Value As Integer)
Row_length = IIF (value = 0, 10, value)
End set
End Property
Public Function S (BYVAL ROW AS INTEGER) AS INTEGER
If Me.Text.length = 0 THEN EXIT FUNCTION 'If no input, the first input is not available.
'Messagebox.show (Me.Text.length, "111")
'MessageBox.show (cstr (me.text.length))
If Me.Lines (row) .length> = row_length - 1 Then 'typically entered 9, the 10th is the return
Return -1
END IF
Return 0
END FUNCTION
Protected Overrides Sub WndProc (Byref M As System.windows.Forms.Message)
Select Case M.msg
Case & H102 'button
'Messagebox.show (111)
Dim keyasc as integer = m.wparam.toint32
MessageBox.show (cstr (keyasc)) IF s (row) = -1 Then
If not (Keyasc = 10 Oralse Keyasc = 13) Then 'Press the Enter, the resin is overtaking
Return
END IF
END IF
End SELECT
Mybase.wndproc (m)
End Sub
Private sub myrichtextbox_textchanged (Byval e as system.eventargs) handles mybase.textchanged
'Messagebox.show (me.text.length)
Row = me.lines.getLength (0) - 1
End Sub
'Private sub myrichtextbox_keypress (Byval e as system.windows.forms.keypressEventArgs) Handles mybase.keypress
'Messagebox.show ("haha")
'End Sub
END CLASS