Do you know that popup/modal forms should never have ShowInTaskbar=True?

Updated by Brady Stroud [SSW] 1 year ago. See history

123

Question: What is wrong with this Picture?

Image

Figure: Can you tell what is wrong with this Picture?

Answer: The 2 SSW SQL Auditor windows are bad, because one is just a modal form.

Note: We don't check for this in Code Auditor because making a form display as popup, is done at runtime via the ShowDialog method.

Dim frm as new frmCustomer frm.ShowDialog

❌ Figure: Figure: Bad Code

If your form is designed to be used modally (and thus be called using ShowDialog) then ShowInTaskbar should be set to false in the form designer.

Dim frm as new frmCustomer frm.ShowInTaskBar = False frm.ShowDialog

❌ Figure: Figure: Bad Code (because this should be set in the form designer)

Dim frm as new frmCustomer frm.ShowDialog

✅ Figure: Figure: Good Code (ShowInTaskbar is set in the form's InitializeComponents method instead)

acknowledgements
related rules