The power of Delphi lies in its vast Component Palette, which allows for Rapid Application Development (RAD). Mastering these common components is the first step in efficient UI building.
1. Basic Display and User Interaction
These components handle displaying static text and capturing simple, single-line input.
| Component | Class Name | Purpose | Key Properties/Methods |
| Label | TLabel | Displays non-editable static text. | Caption (the displayed text), Auto-Size. |
| Edit | TEdit | Captures single-line user input. | Text (stores/retrieves the string value), MaxLength, ReadOnly. |
| Button | TButton | Executes a command when clicked. | Caption, OnClick (main event). |
| CheckBox | TCheckBox | Captures a true/false (on/off) state. | Checked (Boolean state), Caption. |
| RadioButton | TRadioButton | Allows selection of one option from a group. | Checked (Boolean state), Caption. |
| Memo | TMemo | Captures multi-line text input (a scrollable text box). | Lines (a TStrings object containing all lines), ScrollBars. |
Example: Interacting with Input Components
To read data from a text box and display it:
procedure TForm1.btnGreetClick(Sender: TObject);
begin
// Read the current text from the TEdit component
var UserName := edtUserName.Text;
// Check the state of the TCheckBox
if chkActive.Checked then
ShowMessage('Welcome back, ' + UserName)
else
ShowMessage('User ' + UserName + ' is inactive.');
end;
2. Grouping and Organization Components
These controls are non-interactive containers used to organize and structure the UI, making the form cleaner and easier to navigate.
| Component | Class Name | Purpose | Key Properties |
| GroupBox | TGroupBox | Visually groups related controls with a common border and header. | Caption (the header text). |
| Panel | TPanel | A basic container. Used for organizing components or creating toolbars. | BevelKind, Align (crucial for docking/sizing). |
| TabControl | TPageControl | Provides a way to manage multiple screens or pages within a single form. | Pages (a collection of TTabSheet components). |
| Separator | TSeparator | A visual line to break up groups of controls. | Align (to define orientation). |
Tab Control Usage
The TPageControl and its nested TTabSheet components are essential for complex UIs:
- Place a
TPageControlon the form. - Right-click the
TPageControland select “New Page” to add aTTabSheet. - Change the
TTabSheet‘sCaptionproperty (this is the text visible on the tab). - Drop components (e.g.,
TEdit,TButton) directly onto the desiredTTabSheet.
3. Selection Components
These components allow the user to select one or more items from a predefined list.
| Component | Class Name | Purpose | Key Properties/Methods |
| ListBox | TListBox | Displays a list of items where the user can select one or multiple entries. | Items (the list of strings), ItemIndex (the selected item’s index, -1 if none). |
| ComboBox | TComboBox | A drop-down list that saves screen space. | Items, ItemIndex, Style (e.g., fixed list or user-editable). |
| Image | TImage | Displays an image (bitmap, JPEG, PNG). | Picture (loads the image file), Proportional, Stretch. |
Working with Lists
Both TListBox and TComboBox use the Items property, which is a TStrings object. TStrings provides methods for easily managing the list of text lines:
// Example: Adding and clearing items in a ListBox
procedure TForm1.FormCreate(Sender: TObject);
begin
// Add items programmatically
cboOptions.Items.Add('Option A');
cboOptions.Items.Add('Option B');
cboOptions.Items.Add('Option C');
// Set a default selection
cboOptions.ItemIndex := 0; // Selects 'Option A'
end;
procedure TForm1.btnClearListClick(Sender: TObject);
begin
// Clear all items from the list
cboOptions.Items.Clear;
end;
