Click here to Skip to main content
13,453,348 members (51,415 online)
Rate this:
Please Sign up or sign in to vote.
I had a user Control 'UC' which contains only one textbox. & Then using that UC in a windows Form for two times; i want to assign value of one textbox of UC1 to other textbox of can we do this?
Thanks in advance.
Posted 25-Sep-12 1:30am
Updated 25-Sep-12 1:35am

1 solution

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

Solution 1

Create a public property in the usercontrol - in the Getter, return the value of the TextBox.Text. In the setter, set the value. Then, in your parent form, you just copy from one property to the other.

public string Text
   get { return myTextBox.Text; }
   set { myTextBox.Text = value; }

myFirstUC.Text = mySecondUC.Text;
Kapil Manspure 25-Sep-12 8:29am
Thanks friend....but I have to use text change event of user control in that derived it possible to do it? if yes then how? any solution will be appreciate.
Thanks in advance..
OriginalGriff 25-Sep-12 8:42am
Yes - create your own UserControl TextChanged event - the Textbox one triggers that. It's easy to do: there is a tip here that provides the code and a simple way to add it as well if you want:
(You only need the first two code blocks to add an event, the rest of the Tip is about making it quicker to do in Visual Studio, becasue I'm lazy!)
Kapil Manspure 26-Sep-12 2:58am
Thanks OriginalGriff, but Sorry to asked this again I am a newbie in Windows forms & eventHandler, Delegates etc.. so please can you just elaborate some more to use the UC_Validated() event of derived form1 in TEXTCHANGE event of UserControl items? How to handle intercommunication of events?

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 |
Web04 | 2.8.180318.3 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2018
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