Click here to Skip to main content
11,718,589 members (73,706 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: .NET3.5 Windows Forms
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
Edited 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 at 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 at 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 at 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
0 Sergey Alexandrovich Kryukov 651
1 OriginalGriff 210
2 F-ES Sitecore 185
3 Jochen Arndt 160
4 Maciej Los 130
0 OriginalGriff 535
1 Maciej Los 529
2 Richard MacCutchan 440
3 CHill60 415
4 F-ES Sitecore 415

Advertise | Privacy | Mobile
Web03 | 2.8.150901.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2015
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