Linked Control Properties

Linked Control Properties.

Have you ever wanted a control property, such as text on a label, to automatically update whenever a similar property on another control changes?  With VB.Net you can do it the hard way – in code – or you can do it the easy way, in the designer.

Let’s say that you have a form that accesses a customer’s account.  You want that account name to appears in the title bar of every subsequent form that you open while editing that customer’s details, so that it is clear to the operator which account they are working with. Here’s how to do it.

In design mode, on the form where the customer name appears in a text box, select the control that will be the ‘source’ of the text.  In the Properties dialog, expand Application Settings, and click Property Binding.  Click the ellipsis (…) icon that appears.

In the Application Settings dialog, make sure Text is selected.  That’s the property we will be binding.

Click the Drop-down arrow in the right hand column, click New, and enter a name – for example: CustName.   Close the dialogs.

Open the other form, make sure the form is selected (not a control on the form) and select Application Settings / Property Binding again. Click the ellipsis and open the Application Settings Dialog.  Make sure Text is highlighted, click the drop-down arrow and select the same name (eg, CustName).  Repeat for other forms.

Now, whenever the text in the text box on the main form changes, the text in the title bar of the other form(s) will change to match it exactly!

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s