Q 11. Do I need to worry about the anchoring and scrolling capabilities of every form I create?
A. Absolutely not. The majority of forms in most applications are dialog boxes. A dialog box is a modal form used to gather data from the user. A dialog box is usually of a fixed size, which means that its border style is set to a style that can't be sized. With a fixed-size form, you don't need to worry about anchoring or scrolling.
Q12. 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.
Q13. 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).
Q14. 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 15. 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 interval why 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 16. 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 17. 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 18. 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 toolbars?
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 19. 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 20. 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 property
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.
Q13. 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).
Q14. 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 15. 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 interval why 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 16. 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 17. 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 18. 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 toolbars?
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 19. 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 20. 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 property
No comments:
Post a Comment