2010-12-02 5 views

답변

1

우선은,이 ​​텍스트 상자 확장을 사용하고를 RichTextBox에 적용

(아래 코드 전체 버전 검색 가능 here 참조) 예를 들어 ... 이벤트 변경

int maxWordsAllowed = 4; 

private void textChangedEventHandler(object sender, TextChangedEventArgs args) 
{  
    //This get the space character count in your current line 
    if (myRichTextBox.Lines[myRichTextBox.CurrentLineIndex].Split(' ').Length - 1) > maxWordsAllowed) 
     MessageBox.Show("Reached Maximum Words for that line");  
} 
:
public class TextBoxExtension : TextBox 
{ 
public TextBoxExtension(){ } 

public int CurrentLineIndex 
{ 
    get { return this.GetLineFromCharIndex(this.SelectionStart) + 1; } 
} 
} 

그런 다음 다음을 수행