User Controls are commonly used in ASP.NET web sites. Their main idea is to bundle a set of controls (buttons, text fields, textareas, etc) and form a new and more complex control. That could be useful in the case that we want to use the same set of controls and functionality across a number of pages in a site. This tutorial will demonstrate how we can make use of User Controls in WinForm applications to create a Multiple Document Interface (MDI in short). In general, an application can either have a Multiple Document Interface or a Single Document Interface. Their definition and main difference is stated below: Graphical computer applications with a multiple document interface (MDI) are those whose windows reside under a single parent window (usually with the exception of modal windows), as opposed to all windows being separate from each other (single document interface). Further reading on their definition and differences you can find on Wikipedia and on the MSDN Library. In a typical WinForm application or any desktop application, each Window Form represents distinct functionality and serves a specific task. Therefore, we can conclude that we will create separate Forms for each task. The advantage is obvious as each task is ‘grouped’ or to phrase it better is encapsulated within each Form. The disadvantage of such implementation is that our users will have to cope with an application that has numerous windows appearing and disappearing on their desktop and let me share with your a little secret: Most users cannot cope with multiple windows open. They tend to maximize the one that they are currently working with and minimize it to find the next one they need. We may use multi-tasking operating systems but our users are mainly single-task beings. This tutorial will demonstrate how we can make use of UserControls to encapsulate the presentation and functionality of each application task. Our application will have one central/main winform that will load the contents of each UserControl depending on the user selection from the application pull-down menu items. Project Creation Let’s kickstart this tutorial by creating a brand-new project in Visual Studio. We select File/New/Project… and select the “Windows Form Application” project template as shown below. I have named the project as ‘UCApplication’. Customize Skeleton Project The next step is to customize the skeleton project that Visual Studio has created for us. By default Visual Studio has created a single WinForm...read more
Posts Tagged "C#"
A software developer based in Athens, Greece, Apostolos Dountsis, having lived and worked for a decade in Brighton, UK, is now unleashing his expert iOS and web skills in the Greek and international market.
If you feel that the open-source projects that I develop and deliver through the site are worth a penny then you could press the button below to send that penny to me.