Show Contents / Index / Search

The SmartUx Controls

Let’s take a look at how to set up some SmartUx controls.

The SmartUx Button Control

Use the SmartUx button control to place buttons on your session screen. You can handle the ButtonClicked event to perform a variety of actions.

This sample creates a button that closes the Reflection Scratch Pad.

This code creates a button and sets it position, size, and label

ISmartButton button = sessionView.CreateSmartButton();

button.ButtonText = "Hide Notes";

button.StartColumn = 30;

button.StartRow = 5;

button.EndColumn = 50;

button.EndRow = 5;

//Create an event handler for the ButtonClicked event

button.ButtonClicked += new EventHandler(button_ButtonClicked);

'Handle the ButtonClicked event to hide the scratch pad.

static void button_ButtonClicked(object sender, EventArgs e)


   Application app = MyReflection.ActiveApplication;

   IFrame frame = (IFrame)app.GetObject("Frame");

   IView sessionView = frame.SelectedView;

   IIbmTerminal terminal = (IIbmTerminal)sessionView.Control;

   terminal.Productivity.ScratchPadPanelVisible = false;


If you don't want to display the button on the next screen, you'll need to remove it before or after the screen changes:


The SmartDropdown Control

The SmartDropDown control allows you to replace old-style numbered list options with a drop down list.


//Create the dropDown control

ISmartDropDown dropDown = view.CreateSmartDropDown();

dropDown.StartColumn = 25;

dropDown.StartRow = 10;

dropDown.EndColumn = 45;

dropDown.EndRow = 10;

dropDown.AddText("ISPF Options");

dropDown.AddText("Sales Reports");


//Create an event handler for the ValueChanged event

dropDown.ValueChanged += new ValueChangedEventHandler(dropDown_ValueChanged);

In the ValueChanged event, we enter the commands for the selected item in the command field.

static void dropDown_ValueChanged(object sender, string value)

   ISmartDropDown listItem = (ISmartDropDown)sender;

   Application app = MyReflection.ActiveApplication;

   IFrame frame = (IFrame)app.GetObject("Frame");

   IView sessionView = frame.SelectedView;

   IIbmTerminal terminal = (IIbmTerminal)sessionView.Control;

   int selection = listItem.CurrentItemIndex;

      switch (selection)


         case 0:

            terminal.Screen.PutText("ISPF", 23, 1);


         case 1:

            terminal.Screen.PutText("KAYAK", 23, 1);


         case 2:

            terminal.Screen.PutText("PROFS", 23, 1);



            terminal.Screen.PutText("ISPF", 23, 1);





Before the Transmit control key is sent, the dropBox decoration is removed from the view so that it doesn’t appear on the next screen.


Note: If you don’t want to display a SmartUx control on the next screen, you’ll need to remove it before the screen changes.

The RequiredField and Border Controls

The Reflection API provides both RequiredField and Border SmartUx controls. The only difference is the red outline on the required field.

This code draws the required field:

ISmartRequiredField reqField = sessionView.CreateSmartRequiredField();

reqField.StartColumn = 2;

reqField.StartRow = 20;

reqField.EndColumn = 34;

reqField.EndRow = 21;

//Create an event handler for the Deactivated event that occurs when the cursor is moved

//from under the required field.

reqField.Deactivated += new EventHandler(reqField_Deactivated);

The Deactivated event is used to perform a simple validation when the tab position is moved from under the required field.

static void reqField_Deactivated(object sender, EventArgs e)


   Application app = MyReflection.ActiveApplication;

   IFrame frame = (IFrame)app.GetObject("Frame");

   IView sessionView = frame.SelectedView;

   IIbmTerminal terminal = (IIbmTerminal)sessionView.Control;

   if (terminal.Screen.GetFieldText(20,16).Trim().Length < 5){




Like other controls, the required field must be removed before the screen changes.


Add a date picker

The date picker control allows users to select dates from a calendar. The format that is displayed on the date picker and in the values sent to the value changed event is set with the DateMask property. (This property uses Microsoft .NET date and time specifiers.)

//Create the calendar

ISmartDatePicker calendar = sessionView.CreateSmartDatePicker();

//Set the position of the calendar

calendar.StartColumn = 20;

calendar.StartRow = 15;

calendar.EndColumn = 40;

calendar.EndRow = 15;

//Set the displayed value to the international date format

calendar.DateMask = "yyyy/MM/dd";

//Create an event handler for the ValueChanged event

calendar.ValueChanged += new ValueChangedEventHandler(calendar_ValueChanged);

//Add the calendar to the view


The value of the selected date is sent to the ValueChanged event.

static void calendar_ValueChanged(object sender, string value)




Remove the calendar when the screen changes.