Several controls contain a list of properties that can be selected manually. For example, in the User - Info Grid you can select details to display about the user that is currently logged in.
1. Select the grid control and click the smart tag in the top-right corner of the control. This will open up a list of options.
2. Click Choose properties.
3. Enable items in the Available Properties pane that will be shown in the control. The items will be displayed to the user in the order they are added in.
4. Click OK.
The properties are displayed in the control.
Several controls can be populated with data from the database. For example, this could be useful if you wanted to create a new unit and needed to select a color for it from a list of the existing colors.
Let's use the above example to populate a control.
1. Create a new Create Unit form. This contains several controls that can be populated.
2. Add the Generic Listbox control to the form.
3. Click the smart tag in the top-right corner of the control. This will open up a list of options.
4. Click Edit Query.
This opens the Query popup. The query is entered in the top pane. When entering the query you can use existing values and variables using the drop-down lists at the top of the popup as follows:
o Add Control Value: Contains the output values from other controls in the form. This can be useful to filter the list.
o Add Global Variable: Contains global variables from the database. This includes any variable relating to the unit, the station or the user.
When writing the query select a value or variable from the drop-down lists to enter it at the location of the cursor.
5. Click Execute Query to view the results of the query.
If the query is not valid an error will appear. Check that all table and parameter names are correct.
Using the example above will produce a result similar to the following.
The tabs in the lower half of the popup give the following information:
o Variables: Lists all variables included in the query. Enter values for the variables and click Execute Query to test the query.
o Results: Displays the results returned from the database.
o Properties: Lets you select the value that will be returned when an item is selected in the control (ValueMember) and the values that will be displayed in the control (DisplayMember).
The most important information here is the ValueMember as this is the output of the control. This value will either be used to filter other controls or will be used in a stored procedure.
6. Click OK to save the control.
If the output of the control is going to be used
somewhere else then it's a good idea to rename the control to something
more recognizable (e.g., Product
Code or Serial Number).
The name cannot contain spaces.