Binding textboxes inside a Usercontrol

I'm using Visual Studio 2010, C#, a Windows Form application.

I created some user controls with textboxes that will be repeated in several forms.

It works fine however, I need to binding them to a bindingSource in the form in which I place them.
Well, I can't. I marked the controls as Modifier = Public, but, there's no physical way to "Select" an individual textbox to change the binding properties.

How do I do that?

I guess it has to be by code.
What's the proper way to do this?






LVL 1
fischermxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
You can expose the TextBox by adding a property to your UserControl, as demonstrated below. Alternatively, you can expose only the members you are interested in instead of the entire TextBox.
public partial class UserControl1 : UserControl
{
    public UserControl1()
    {
        InitializeComponent();
    }

    // Expose TextBox to outside world
    public TextBox YourTextBox { get { return this.textBox1; } }
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fischermxAuthor Commented:
Thank you!, that worked...

A side question on the topic, how do I make these properties to be grouped together in the Properties window?

I know there's a tag for Categories that works when one choose that ordering.

But there's also a way when a property is marked with a tiny horizontal arrow point, like the Font property, then it display a lot of properties inside.
How do I do that?
0
käµfm³d 👽Commented:
That is a whole other topic that I'm afraid I don't have much experience with. I can, hopefully, point you in the right direction. See:

0
fischermxAuthor Commented:
Thank you!!
0
käµfm³d 👽Commented:
NP. Glad to help  : )
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.