473,395 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Having problem reading a RichTextBox after handling a KeyPress Event

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.


Nov 21 '05 #1
0 1238

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: One Handed Man | last post by:
How can one fire an event programatically for a given control. In another post someone wanted to cause an event in order to make a RichTextBox scroll down. However, the onVscroll method is a...
4
by: One Handed Man | last post by:
Ive been working on this since yesterday and its bugging me. Although the event is firing, The box does not scroll. Can anyone see what Im doing wrong. I suspect it is stupidly simple. TIA
9
by: Lars Netzel | last post by:
If I press the Key "a" on the keyboard, all the events and properites will only give me "65" as keycode.. and I want it to give me "a". If I use the KeyPress event.. then I will have access to...
2
by: Phill. W | last post by:
How do I propagate an Event that I've just handled? I have a UserControl containing, among other things, a TextBox. The UserControl handles KeyDown/KeyPress Events for both itself and the...
1
by: rs | last post by:
I am trying to override the keypress fucntion in a form as the following Private Sub rtbInput_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles...
3
by: Stuart Nathan | last post by:
In VB - Visual Studio 2003 As I understand it, in the KeyDown event of a RichTextBox, I can put If e.KeyCode = Keys.Return then e.Handled = False and this will prevent the Enter key being added...
1
by: papalarge | last post by:
Hey all... I've been using the following to calculate the height the textbox needs to be in order to grow it vertically to its necessary size. textbox1.Height =...
1
by: JDeats | last post by:
I have a WinForm with a single command button in the middle, I have added a KeyDown event handler to the form and the method for this is: private void Form2_KeyDown(object sender, KeyEventArgs e)...
8
by: poko | last post by:
I'd appreciate it if someone could help me out with this. Currently I am handling instances of the 'enter' key being pressed as: this.txtBox1.KeyPress += new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.