Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a usercontrol,in the usercontrol there is a textbox,so i want to access the every letter continiously in a variable from the textbox of usercontrol on evert key pressing from keyboard.

If u will guide me through code,so it will be better for me.
Posted
Updated 1-Oct-12 22:47pm
v2
Comments
Sandeep Mewara 2-Oct-12 5:01am    
1. Not too clear.
2. What have you tried?

Define a KeyPress event and track the letters.
StackQ 2-Oct-12 5:14am    
i have a UC Component, in which i have taken a textbox(UserControl.TextBox1.Text).In my Form1 i m using 2 UserControl(UserControl1 and UserControl2).I want the code through which text of UserControl1.TextBox1.Text should show in UserControl2.TextBox1.Text,simultaneouly as i m entering values in UserControl1.TextBox1.Text.

In brief-
1-Suppose i have to write ME,so first i will enter M in UserControl1.TextBox1.Text(here i m entering the values in UserControl1.TextBox1.Text but it should also show in UserControl2.TextBox1.Text) like (on the keypress event of textbox1 --textbox2.text=textbox1.text)
StackQ 2-Oct-12 5:16am    
if u can solve this problem through delegate,so plz provide me solution through delegate.

1 solution

1. Your UserControl needs a custom event: TextBoxTextChanged with its signature like a standard EventHandler[^]. Fire the event whenever the TextBox[^] fires its TextChanged[^] event.
2. Your UserControl needs a public property TextBoxText, too. Implement only the getter part returning the TextBox's current text.

3. The second UserControl needs to subscribe to the first UserControl's TextBoxTextChanged event. Upon firing of the event, an event handler routine will be called. In the event handler, copy text from sender's TextBoxText property (if existing) to this.TextBox1.Text (or whatever it is actually called).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900