Component Not Found
Delphi Programming Language
Severity: ModerateWhat Does This Error Mean?
This error occurs when Delphi tries to load a DFM file that references a component which no longer exists in the form. The DFM may still contain property values pointing to a component that was deleted from the form designer. The fix is to open the DFM as text, find the stale reference, and remove it.
Affected Models
- Delphi 10.4 Sydney
- Delphi 11 Alexandria
- Delphi 12 Athens
- Embarcadero RAD Studio
- Free Pascal / Lazarus
Common Causes
- A component was deleted from the form designer but a property of another component still references it by name
- A DFM was edited in a text editor and a component block was removed without removing all references to it
- Version control merge conflict resulted in a DFM where references are out of sync with component declarations
- Renaming a component left old name references in another component's properties
- A data-aware control's DataSource or DataField property points to a dataset component that was removed
How to Fix It
-
Note the component name mentioned in the error. Right-click the form in the IDE and choose View as Text to open the DFM as plain text.
The error message usually says something like 'Component ''ButtonOk'' not found' — search for that name in the DFM text.
-
Search the DFM text for all occurrences of the missing component name. Remove any property assignments that reference it, such as: Default = ButtonOk or CancelButton = DeletedButton.
Properties like Default, Cancel, ActiveControl, DataSource, and ImageList can hold references to other components by name.
-
Save the DFM text file, then re-open the form in the IDE. If the form opens cleanly, the stale reference has been removed.
If the IDE refuses to open the form, the DFM may have additional structural errors — check for mismatched object/end blocks.
-
After fixing the DFM, check the form's Pascal unit for any code that references the deleted component. The code will not compile if it references a field that no longer exists.
Each component on a form has a corresponding field declaration in the form class. When you delete a component in the designer, Delphi removes the field — but manual DFM edits may leave the field behind.
-
To prevent this in the future, always delete components through the form designer, not by editing the DFM text directly. The designer removes all cross-references automatically.
If you must edit the DFM as text, search for every reference to the component you are removing, not just its object block.
When to Call a Professional
The DFM stores all component relationships as text — when a component is removed, Delphi usually updates references, but this can fail. Open the DFM as text, search for all occurrences of the missing component's name, and remove or fix those references. After saving the DFM text and re-opening the form, the error should be gone.
Frequently Asked Questions
Can I use FindComponent to check if a component exists before accessing it?
Yes. FindComponent('ComponentName') returns nil if the component does not exist. This is useful in code that uses component names dynamically. However, the 'Component not found' DFM loading error happens before your code runs — it is a streaming error, not a runtime lookup error.
Why does Delphi not automatically clean up stale references when I delete a component?
Delphi's form designer does clean up most cross-references automatically. The stale reference problem usually occurs when the DFM is edited as text, restored from version control, or a merge conflict is resolved incorrectly. The designer cannot know about changes made outside of it.
Will this error affect end users if it only happens in the IDE?
If the DFM is embedded in the executable (which is the default), the same stale reference will cause the same error at runtime when the form is loaded. Fix the DFM in development before shipping. The error affects both IDE loading and runtime loading because they use the same streaming mechanism.