473,386 Members | 1,757 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,386 software developers and data experts.

How to send a char to TextBox

Hi
How can I send a char to Textbox so that KeyPress event is called? I have a button and with a click I would like to send a char, e.g. "C", to the Textbox. But Textbox1_KeyPress is not catching the event (I can step thru KeyPress ok but nothing goes to TextBox). KeyPress itself works fine with key stroke via keyboard

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Clic
Dim e2 As New System.Windows.Forms.KeyPressEventArgs(CType("C", Char)
TextBox1_KeyPress(TextBox1, e2
End Su

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPres
If Not Char.IsLetter(e.KeyChar) And Not Char.IsControl(e.KeyChar) The
e.Handled = True ' ignor
End I
End Su

TIA.
Nov 20 '05 #1
7 4534
To clarify. KeyPress is called just that no text goes to textbox via button click.
Nov 20 '05 #2
* "=?Utf-8?B?c2NvdHRpZWRvZw==?=" <an*******@discussions.microsoft.com> scripsit:
How can I send a char to Textbox so that KeyPress event is called?


Maybe by using 'SendKeys.Send' -- nevertheless, why do you want to do
that?!

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Website Address Changed!
Nov 20 '05 #3
I'm creating a calculator type application. Plain SendKeys won't work. Or perhaps I don't know how to use SendKeys. Any suggestions?
Nov 20 '05 #4
use texbox1_change or somthing around that.

"scottiedog" <an*******@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
I'm creating a calculator type application. Plain SendKeys won't work.

Or perhaps I don't know how to use SendKeys. Any suggestions?
Nov 20 '05 #5
* "Chris Barrell" <ch***********@bigpond.com> scripsit:
use texbox1_change or somthing around that.


?!?

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Website Address Changed!
Nov 20 '05 #6
Ummm... I'll offer the suggestion that you are going about this "backwards"
(tm)

Rather than designing "intelligent systems" in the UI you might try build a
Calculator Class, then databind to the textbox. As you enter data the
Calculator object will validate not a keypress or some other UI event. That
way if the calculator "totals" and the accumulator property is changed in
the Calculator object it will automatically (through binding) be shown in
the textbox also.

Tom

"scottiedog" <an*******@discussions.microsoft.com> wrote...
I don't know what you mean by text change.
My problem is that I can call keypress event successfully but nothing happens to textbox. No entry to the textbox. Think of what I'm trying to do as a calculator app but I have to do some validation so I must go through KeyPress event whether it is via keyboard or button click event (sending char to textbox).

TIA

Nov 20 '05 #7
Actually, SendKey worked. I had to give focus to the textbox first. Thanks
About the class, it is interesting approach. This means that I won't need textbox after all
I would just print out the result to, say label as I capture the key stroke (or button click), calculate, and then to label
Not bad at all

Thanks guys.
Nov 20 '05 #8

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

Similar topics

6
by: Tom | last post by:
I try to write a simple tcp based job queue server. It's purpose is to get commands from a client and store them in a queue (STL). The server has a thread which checks periodically the queue,...
3
by: HuYi | last post by:
Hi,everyone,I want to get a string as '\u65e0\u6cd5' in TextBox,but when I trace the program,I found that TextBox.Text=@"\u65e0\u6cd5", But I want "\u65e0\u6cd5",not @"\u65e0\u6cd5". I used...
3
by: Dakkar | last post by:
I want to make a password system like this every character will have an equal character for example a will be equal to g and b will be equal to f when person writes ab it will change automaticly...
3
by: Simon | last post by:
Hi, I have webpage (sql.aspx) in asp.net with a big textbox. In this box, I generate SQL queries. Some of the queries can takes more than 2000 characters lenght. I want to send the content of the...
2
by: Husam | last post by:
Hi EveryBody: I made windows application project as e-mail sender. This project consist of 13 textbox and one label and one button. I add {system.web.dll} as refrance to this project to help me...
14
by: Professor Yonce | last post by:
I have made form for E-Mail. I have entered code but the Import system does not work. It has squiggly line underneath it showing it is not communicating. It Will not build. Public Class...
3
by: YMPN | last post by:
Hi Everyone, I'm deen from Riyadh. Please do help me with some problem i have. I have this formview control setup to recieved inputs from user (textbox, dropdownlist, others). After...
3
by: =?Utf-8?B?QmVybmFyZG8gU2FsYXphciBuZXdi?= | last post by:
Hi everybody... i need help with this issue: i have a textbox control with the focus. at side, i have a datagridview control populated with some data. i need to control behavior of dgv control...
7
Atran
by: Atran | last post by:
Hello, I use Html 4.0 in Dreamweaver program, to send an email, I know that I must put a Form, and I make the Form Action: mailto:MyEmail@hotmail.com Then I put to the Form three textboxes:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...

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.