Hi, I'm trying to record the text value of a RichTextBox after handling a
KeyPressEvent (each time the user types a char). But what I'm seeing is
that the value of rtb.Text is equal to the value of the contents of the
RichTextBox prior to the event being triggered.
For Example, here's the code:
Sub x
...
AddHandler rtb.KeyPress, AddressOf CellEvent_KeyPress
...
end sub
Private Sub CellEvent_KeyPress(ByVal sender As Object, ByVal e As
KeyPressEventArgs)
Dim rtbSender As RichTextBox = CType(sender, RichTextBox)
Console.WriteLine("Cell Contains => " + rtbSender.Text)
End Sub
So if I type '1', I get:
Cell Contains =>
If I follow that with a '2', I get:
Cell Contains => 1
Then adding a '3', I get:
Cell Contains => 12
You get the idea.
How do I force rtbSender.Text to update with the current text of the object
at that point?
As a workaround I can append an "e.KeyChar" to the end of the string, but
that seems a bit strange to have to do that. Maybe someone can explain why
the .Text property is not being updated at that point.