Q. How do I know whether a project is a candidate for an MDI interface?
A. If the program will open many instances of the same type of form, it's a candidate for an MDI interface. For example, if you're
creating an image-editing program and the intent is to enable the user to open many images at once, MDI makes sense. Also, if you'll
have many forms that will share a common toolbar and menu, you might want to consider MDI.
Q. Can I place radio buttons directly on a form?
A. Yes. The form is a container, so all radio buttons placed on a form are mutually exclusive to one another. If you wanted to add a
second set of mutually exclusive buttons, they'd have to be placed on a container control. In general, I think it's best to place radio
buttons in a group box rather than on a form because the group box provides a border and a caption for the radio buttons and makes
it much easier to move around the set of radio buttons when you're designing the form (you simply move the group box).
Q. I've seen what appear to be list boxes that have a check box next to each item in the list. Is this possible?
A. Yes. In Visual C# 2005, this is accomplished using an entirely different control: the checked list box.
Q. What if I need a lot of timers, but I'm concerned about system resources?
A. When possible, use a single timer for multiple duties. This is easy when two events occur at the same intervalwhy bother creating a
second timer? When two events occur at different intervals, you can use some decision skills along with static variables (discussed in
Hour 11) to share Timer events.
Q. What else can I do with an Image List control?
A. You can assign a unique picture to a node in a Tree View control when the node is selected. You can also display an image in the
tab of a tab page in a Tab control. There are many uses, and as you learn more about advanced controls, you'll see additional
opportunities for using images from an Image List.
Q. I have a number of forms with nearly identical menus. Do I really need to take the time to create menus for all these forms?
A. Not as much as you might think. Create a MenuStrip control that has the common items on it, and then copy and paste the control
to other forms. You can then build on this menu structure, saving you a lot of time. Be aware though, that when you copy and paste a
control, the corresponding code does not get copied.
Q. I've seen applications that allow the end user to customize the menus and toolbars. Can I do that with the Visual C# menus and
A. Yes and no. There is no built-in functionality to do this, so you would have to write LOTS of complicated code to allow users to
customize your toolbars. A better approach is to purchase a third-party component that provides this functionality. Personally, I think
buying a component that supports this is a much better option than attempting to write the code yourself.
Q. Do I need to pay much attention to scope when defining my procedures?
A. It might be tempting to create all your methods as public, but this is bad coding practice for a number of reasons. For one thing,
you'll find that in larger projects, you have methods with the same name that do slightly different things. Usually, these routines are
relevant only within a limited scope. However, if you create all public methods, you'll run into conflicts when you create a method
with the same name in the same scope. If the method isn't needed at the public level, don't define it for public access.
Q. What is a "reasonable" number of classes?
A. This is hard to say. There really is no right answer. Instead of worrying about an exact count, you should strive to make sure that
your classes are logical and that they contain only appropriate methods and properties.