Click here to Skip to main content
12,402,202 members (72,355 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
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 1-Oct-12 22:46pm
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.
01010RAJ 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)
01010RAJ 2-Oct-12 5:16am
   
if u can solve this problem through delegate,so plz provide me solution through delegate.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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).
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100