Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DXWIN0005: A Form Dialog is Never Disposed

In This Article

Severity: Warning

Any Form displayed as a dialog (with the System.Windows.Forms.Form.ShowDialog method) must be disposed when not needed anymore. Otherwise, it may cause memory leaks.

#Invalid Code

C#
Form dialog1 = new Form();
dialog1.ShowDialog();

#Valid Code

C#
using (Form dialog1 = new Form()) {
    dialog1.ShowDialog();
}

// or

Form dialog1 = new Form();
dialog1.ShowDialog();
dialog1.Dispose();