2012-06-11 3 views
1
Private Sub RichTextView_TextChanged(ByVal sender As Object, ByVal e As 
    KeyPressEventArgs) Handles RichTextView.KeyPress, RichTextView.TextChanged 

    Dim c As Char = e.KeyChar 
    Dim i As Integer = Asc(c) 
    Dim h As Char = Chr(i) 

capitalise_first_letter.Add(h) 
End Sub 

KeyPressEventArg 수 : Unable to cast object of type 'System.EventArgs' to type 'System.Windows.Forms.KeyPressEventArgs'. 그것은 capitalise_first_letter.Add(h)에서 오류를 (capitalise_first_letter은 문자열의 목록입니다)가 발생합니다.변수는 위의 코드는 오류가 발생

왜? h는 e.KeyChar이므로 변환을 수행합니까?

답변

3

동일한 루틴을 사용하여 RichTextView.TextChanged을 처리하려고 시도했기 때문에 이는 KeyPressEventArg을 전달하지 않기 때문입니다.

TextChanged 이벤트에 대해 별도의 이벤트 처리기가 필요하며이 경우 KeyPressEventArgs이되도록 허용해야합니다.

+0

와우. 감사! –

관련 문제