Exercise 7: Load steel materials from catalog to selection form
You will learn how to enumerate through the catalogs and customize the list of items shown in the form.
After downloading the TSOpenAPISelfLearningExercises package from GitHub (button above), find the example code for this exercise at \Exercise7-UI-Load-Steel\ folder.
Before you start, Open the project that you created in exercise 6.
Load steel materials from catalog to selection form
Modify the last exercise so that you add two more events:
-
Load steel materials from the catalog when the form is loaded
-
Add the steel materials to the material selection form
Follow these steps to create your application:
-
Create an instance of List<MaterialItem>
-
Add a textbox to the form for the user to give the material.
-
Add a button to the form that selects the material, the click-event should include the following:
-
Create a new MaterialSelectionForm.
-
Set values to the material textbox.
-
-
Create a OnLoad event that loads steel materials from the catalog, the event should include the following:
-
Create a new CatalogHandler.
-
Select all material items from model to enumerator using MaterialItemEnumerator.
-
Loop through enumerator.
-
See if an item has steel as material and add it to material list.
-
-
Modify the hardcoded value for material in the code. Use value defined in the textbox.
-
Test your application.
Your application form should look something like this: