سؤال

ولدي مساحة النص وظيفة للقيام تسليط الضوء على تركيب عليه. والآن يقرأ RichTextBox بأكمله. كيف يمكنني الحصول على متغير سلسلة تحتوي على السطر الحالي؟ فيما يلي رمز لدي حاليا.

Private Sub HighLight()
    Dim rm As System.Text.RegularExpressions.MatchCollection
    Dim m As System.Text.RegularExpressions.Match
    Dim x As Integer ''lets remember where the text courser was before we mess with it

    For Each pass In FrmColors.lb1.Items
        x = rtbMain.SelectionStart
        rm = System.Text.RegularExpressions.Regex.Matches(LCase(rtbMain.Text), LCase(pass))
        For Each m In rm
            rtbMain.Select(m.Index, m.Length)
            rtbMain.SelectionColor = Color.Blue
        Next
        rtbMain.Select(x, 0)
        rtbMain.SelectionColor = Color.Black
    Next
End Sub
هل كانت مفيدة؟

المحلول

وليس حاولت ذلك لكن:

rtbMain.Lines(lineNumber)

وإذا لم يكن تعيين خاصية خطوط لمجموعة والوصول إلى عنصر صفيف.

نصائح أخرى

وأعتقد أنك تريد

rtbMain.Lines(rtbMain.GetLineFromCharIndex(rtbMain.SelectionStart))
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top