Table of Contents

Address Entry and Validation

TTMSFNCIPEdit provides segmented entry for network-style values. Use it when users need to enter IPv4, IPv6, or MAC addresses without manually typing separators in a plain edit control.

IPv4 Entry

Set IPAddressType before assigning values. IPv4Address is available only while the control is in IPv4 mode; using it in another mode raises an exception.

IPv4 editor

procedure TForm1.ConfigureIPEdit;
begin
  TMSFNCIPEdit1.IPAddressType := IPv4;
  TMSFNCIPEdit1.IPAddress := '192.168.0.10';
  TMSFNCIPEdit1.OnChange := TMSFNCIPEdit1Change;
end;

IPv6 and MAC Modes

Switching IPAddressType resets the fields to the default shape for the selected mode. Use IPAddress for formatted IPv6 or MAC strings, and use IPv6Address when you already have the four-part record value.

IPv6 editor

procedure TForm1.ConfigureAddressModes;
begin
  TMSFNCIPEdit1.IPAddressType := IPv6;
  TMSFNCIPEdit1.IPAddress := '0000:0000:0000:0000:0000:0000:0000:0001';

  TMSFNCIPEdit2.IPAddressType := MAC;
  TMSFNCIPEdit2.IPAddress := '00-11-22-33-44-55';
end;

Change Handling

Handle OnChange when the form needs to validate dependent fields, enable an apply command, or store the current address.

procedure TForm1.TMSFNCIPEdit1Change(Sender: TObject);
begin
  Caption := TMSFNCIPEdit1.IPAddress;
end;

Combining address mode, validation, and change handling

The following example switches mode based on a combo box selection, validates on every change, and enables a Save button only when the address is complete:

procedure TForm1.cboModeChange(Sender: TObject);
const
  Modes: array[0..2] of TIPAddressType = (iatIPv4, iatIPv6, iatMAC);
begin
  TMSFNCIPEdit1.IPAddressType := Modes[cboMode.ItemIndex];
  TMSFNCIPEdit1.Clear;
  btnSave.Enabled := False;
end;

procedure TForm1.TMSFNCIPEdit1Change(Sender: TObject);
begin
  btnSave.Enabled := TMSFNCIPEdit1.IsValid;
  lblAddress.Caption := TMSFNCIPEdit1.IPAddress;
end;

procedure TForm1.btnSaveClick(Sender: TObject);
begin
  SaveAddress(TMSFNCIPEdit1.IPAddress);
end;

Styling

Use IPAddressFont for the field text. Fill and Stroke control the surrounding surface, so align them with adjacent edit controls when the address editor appears inside forms or property panels.