Basic Application Design Question

I am new to windows forms as all of my previous work has been web applications. With that said, please forgive what may be a simple question. I am building an application that looks as follows:

Toolbar
TreeView

DataGridView

TabControl

Based upon the node selected in the TreeView, the right pane may display as above or it may contain a different set of controls. In addition, based the row selected in the DataGridView, the data binding or layout of the TabControl may change.

Assuming this all makes sense to everybody, here is my question. What is the best approach for designing this type of application Do I encapsulate items into User Controls Other options



Answer this question

Basic Application Design Question

  • gregmlucas

    Thank you for your response. So, if I went with the UserControl approach, all of the "display logic" or event handling is written within the code of the MainForm, correct So, in other words, if I want to handle the OnCellContentClick event of the DataGridView which is sitting within a UserControl to alter the UserControl that displays below, I would have to expose this event to my MainForm, correct

    Sorry for the simple question....just new this so any help you could provide is appreciated.


  • kentz

  • TMTNJ

    Try to handle the events at the lowest level you can by adding user controls for each control that will need significant display logic event handling. For example you can put the Treeview inside its own user control name treeHost.

    Inside treeHost you handle details that the main program doen't care about such as, adding treeNodes and setting their image indexes, managing the imageList, etc. However events such as AfterSelect may need to get sent to the main program. You will need to propagate the important events.

    You might to have a user control named DisplayHost (for the right side) Display host contains two other user controls (gridHost and TabHost). Each host handles it's own details.

    This way the main form doesn't get too much code when the program starts to grow in size.

    This approach requires a little extra work. You will need to add code to propogate some events that the Main program or other control hosts need to know. You will proabably need to create your own events.


  • StressPaul

    No, you would implement all the logic of the UserControl inside the control itself, just like you would with an MDI child form.

  • sharonl327

    You might be looking for an MDI application. Using UserControls is also an option. Either one will work fine; I would suggest MDI, as it makes more logical sense with what you are trying to do, but neither approach is clearly better than the other (UserControls are basically just mini-forms anyway).

  • Basic Application Design Question