Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First I would suggest to separate independent user-interface parts into UserControls or Components. Then - if needed - wire them using Events (eg. your own specialized events and properties.</p> <p>For example you can place your main content (the TabControl / Container) in a UserControl and place that user control in the main form. All tab-/page-switching logic/UI etc. then belongs to that user control. In that UserControl you can define for example your own Event that gets fired when the user switches a tab. The main form then can register to this event - just like it can for other Winforms-control-events - and do its stuff (eg. change the window title to represent the currently active tab).</p> <p>Then next you can move the content of each tab to its own user-control and use these user-controls within your new tabs-usercontrol. Move the logic down to the UserControl which is responsible for the given task.</p> <p>A form/controls hierarchy from some typical application could look like this:</p> <ul> <li>MainForm (Form) <ul> <li>MainTabContainerControl (UserControl)</li> <li>Page1Control (UserControl)</li> <li>Page2Control (UserControl) <ul> <li>MyImprovedDbRowGridControl (UserControl or Component)</li> </ul></li> <li>Page3Control (UserControl)</li> <li>SidebarControl (UserControl)</li> <li>SearchControl (UserControl) <ul> <li>MyImprovedDbRowGridControl (UserControl or Component)</li> </ul></li> <li>QuickHelpControl (UserControl)</li> </ul></li> </ul> <p>Next thing is so keep all the UI-eventhandlers as small as possible and doing only UI stuff. Move other logic like business- or dataaccess-logic to other classes outside of the user-interface.</p> <p>If you have combinations of the controls that are needed more then once in the application: move them to a re-usable UserControl. (eg. breadcrum).</p> <p>Regarding your sample code you can make it more compact and therefore maintainable by simplyfing its logic:</p> <pre><code>if (this.fSelectedButton.Equals(this.RadioButton_Delete)) { this.TextBox_DestinationFile.Enabled = false; this.Button_DestinationBrowse.Enabled = false; } else { this.TextBox_DestinationFile.Enabled = true; this.Button_DestinationBrowse.Enabled = true; } </code></pre> <p>...could be:</p> <pre><code> var delete = fSelectedButton == RadioButton_Delete; this.TextBox_DestinationFile.Enabled = !delete; this.Button_DestinationBrowse.Enabled = !delete; </code></pre> <p><strong>Update:</strong> When it comes to refactoring and code-cleanup a very usefull tool is <a href="http://www.jetbrains.com/resharper/" rel="nofollow">Resharper</a> (R#). I can highly recommend it.</p> <p>Hope this gives you some ideas where to start.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. 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