Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not 100% sure that I got all the possible cases from there, but with generics and overloading you can compact this down to something that would be a lot easier to maintain. Here's my go at it:</p> <pre><code>using System.Windows.Forms; using DevExpress.XtraEditors; using DevExpress.XtraTab; namespace psWinForms { public static class WinFormCustomHandling { public static void ShowFormInControl&lt;FormType, ControlType&gt; (FormType frm, ref ControlType ctl, FormBorderStyle style) where FormType : Form where ControlType : Control { ShowFormInControl&lt;ControlType&gt;(frm, ref ctl, style, 0, 0); } public static void ShowFormInControl&lt;FormType, ControlType&gt; (FormType frm, ref ControlType ctl, FormBorderStyle style, FormWindowState? state) where FormType : Form where ControlType : Control { if (state.HasValue) frm.WindowState = state; ShowFormInControl&lt;ControlType&gt;(frm, ref ctl, style, 0, 0); } public static void ShowFormInControl&lt;FormType, ControlType&gt; (FormType frm, ref ControlType ctl, FormBorderStyle style, int left, int top) where FormType : Form where ControlType : Control { ShowFormInControl (frm, ref ctl, style, left, top, null); } public static void ShowFormInControl&lt;FormType, ControlType&gt; (FormType frm, ref ControlType ctl, FormBorderStyle style, int left, int top, string title) where FormType : Form where ControlType : Control { frm.TopLevel = false; frm.ControlBox = false; frm.Parent = ctl; frm.FormBorderStyle = style; frm.Left = left; frm.Top = top; frm.Width = ctl.Width + 4; if (null != title) frm.Text = title; frm.Dock = DockStyle.Fill; frm.Show(); //IMPORTANT: .Show() fires a form load event frm.BringToFront(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload