2012-01-25 8 views

risposta

3

RichTextBox è un tipo FlowDocument e che non dispone di una proprietà Lines. Quello che stai facendo sembra una buona soluzione. Potresti voler usare IndexOf invece di dividere.

È inoltre possibile aggiungere un metodo di estensione come l'articolo suggerisce:

public static long Lines(this string s) 
{ 
    long count = 1; 
    int position = 0; 
    while ((position = s.IndexOf('\n', position)) != -1) 
     { 
     count++; 
     position++;   // Skip this occurance! 
     } 
    return count; 
} 
Problemi correlati