BuddyProperty Property

Sets or returns the property of the buddy control that is to be modified.

object.BuddyProperty as String

Use

How the Buddy Properties work together

The BuddyControl property specifies another control on the form that will update when this control is clicked. When this property is set, clicking on the active control will modify the contents of it's buddy control also. Some host-generated controls, such as menu buttons and option buttons have automatically populated buddy properties . These controls have one thing in common, they are usually part of a group of individual controls that are associated with a single entry field. The buddy processing determines what value to send to the entry field and which field to send it to.

A buddy control can be specified using either the control name, or the row and column position of the corresponding host field using the following syntax:

row,column

The BuddyProperty is the specific property of the buddy control that will be populated with the value of the active control when clicked.

TIP!

If you specify the BuddyControl property you will need to also set the BuddyProperty property. Where the BuddyControl is a textbox, the BuddyProperty is typically set to Text. If the BuddyControl is a label, then the BuddyProperty is usually set to Caption.

If the BuddyValue property is left blank then the value sent to the buddy control will be the current value of the active control. If a BuddyValue is specified then the specified value will be sent to the buddy control when the active control is clicked.

For CheckBox controls the BuddyValue property can be specified as two values. The first value is used when the check box is checked and the second value is set when it is cleared. The two values are specified using a semi-colon to separate them like the following example:

checkedValue;uncheckedValue

If a BuddyKey is specified, then, after the active control is clicked, the focus will be moved to the buddy control and the specified AID key will be sent to the host when the buddy control is modified.

WATCH OUT FOR..

Buddy processing is tied to the click event of the active control, therefore setting a buddy control does NOT mean that the two controls are synchronized. The buddy control is only updated when the user clicks on the active control. Any changes to the value of the active control via other means, for instance a script or macro, will not modify the buddy control.

Example

Let's take a look at a host screen example. The "DocSighted" field at the bottom of the screen below is a perfect candidate to be replaced with a check box. The field accepts two possible values and a checkbox would ensure that users enter an accurate value into the field. The value of this check box however needs to populate the host-generated "DocSighted" field. We could do this by writing a macro or script to populate the control but the easier method is to assign a buddy control to the inserted check box.

Here's how we could go about it:

  1. Turn off the visibility of any fields that we no longer want to appear on the screen. In this case we would set the Visible property of the entry field and the field choice values to False.
  2. Insert a new control on the form. In this example we would insert a CheckBox control next to the Documents Sighted field prompt.
  3. Set the BuddyControl property of the new control to the control that you wish to modify. Here we would set the BuddyControl property of the checkbox to either 20,23 (which is the row, column co-ordinates of the field), or to the name of the field DocSighted.
  4. Set the BuddyProperty to the relevant property that you wish to set in the BuddyControl. In this case it is the text property so we would set this to Text.
  5. If relevant, set the BuddyValue to the value that you want send to the buddy control. In the example above, a checkbox will typically return True or False depending on its state however we want to send the field choices Sighted or Unsighted to the entry field therefore we would enter Sighted;Unsighted as the BuddyValue.
  6. If you also wanted to send an AID key to the host upon entry of this field then you could select one from this property's drop down list. In this scenario we do not need to do this.

Now when the user clicks the new checkbox the text "Sighted" will be sent to the hidden DocSighted entry field and the text "Unsighted" will be sent when the user un-checks the control.

See Also

BuddyControl property | BuddyKey property | BuddyValue property | Properties

Applies To

CommandButton control | Check box control | PicutreBox control | Label control | Menu button control | Option button control | UpDown control


© 2004-2021 looksoftware. All rights reserved.