24-08-13, 02:44 PM
بصراحة شوي معقد تصميمها من حيث الاحداث لان مابها حدث Paint وحتى اعادة القيادة لايتم اقتناصه واذا قمنا بتحديد النص راح يتغير اللون
ضلت مشكلة الاحداث
فما الحل؟
ضلت مشكلة الاحداث
كود :
Public Class TextBox
Inherits System.Windows.Forms.TextBox
Public Sub Changed_Color(ByVal txt As String, ByVal clr As Color)
If Me.Text.Contains(txt) Then
Dim SB As New SolidBrush(clr)
Dim G As Graphics = CreateGraphics()
Dim i As Integer = Text.IndexOf(txt) + Len(txt)
Dim P As Point = GetPositionFromCharIndex(i)
P.X -= 2
P.Y += 1
G.DrawString(txt, Font, SB, P)
End If
End Sub
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
End Sub
End Classكود :
Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.Changed_Color("السلام", Color.Blue)
End Subفما الحل؟

