Transfer data from a user control textbox to textbox on a form - c#

I have a user control I made on a windows form.  When the control is activated the user there are several texboxes on it containing int32 values based on user input in/on the control.  I would like to have these values transfer to textboxes on the windows form, so the data from the control is included in the dataset update to the database.
TrackerGroupAsked:
Who is Participating?
 
p_davisConnect With a Mentor Commented:
TextBox tb = userControl.Controls["controlName"] as TextBox;
formTextBox.Text = tb.Text;
0
 
p_davisCommented:
you can databind as well

formTextBox.DataBindings.Add("Text", tb ,"Text");
0
 
Joseph HornseyPresident and JanitorCommented:
TrackerGroup,

You might want to post some of the code.  But, off the top of my head, here are some things that I could point out:

1. "there are several texboxes [sic] on it containing int32 values"
Textboxes don't contain int32 datatypes.  The x.Text property of the textbox contains a String.

2. To make the text in one textbox populate into another textbox, it should be relatively easy:
TextBoxB.Text = TextBoxA.Text

3. Keep in mind that the update to the database is not necessarily impacted by whether or not you've put values into textboxes.  You could always simply take the values straight from the control and update the database:

Dim TextString as String
Dim TextInt as Integer

TextString = TextBoxA.Text
TextInt = Convert.ToInt32(TextString)

<Code to Connect to Database>
<Code to Update Database>

Does that help at all?

<-=+=->
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
TrackerGroupAuthor Commented:
You are awesome!!  Thank you so very much for your quick response!!  It works perfectly.
0
 
TrackerGroupAuthor Commented:
It took me longer researching this on my own than asking an expert.  I should have asked the experts first.  Thanks Experts-exchange.
0
 
p_davisCommented:
thanks for the compliment, i am glad it worked for you.
0
All Courses

From novice to tech pro — start learning today.