Below is the reasons of developing custom control:
- To reduce the overall development time - in Visual Studio, the custom control can be drag from the Toolbox and drop onto any WinForm or UserControl. Note: the custom control that you have added to the project will appear in the Toolbox after you have compiled the project or solution (if your custom control is residing in other project).
- To reduce the testing time - this requires test once only because the control is reusable.
- You are working on system that requires to capture "record status" which is used in many screens.
- The user might request for enhancement on this input control but the enhancement is not an urgent priority now
- You are splitting the system into multiple small section to be handle by different programmer.
public class StatusComboBox : ComboBox { public void RefreshData() { this.Items.Clear(); this.Items.Add("Pending"); this.Items.Add("In Progress"); this.Items.Add("Completed"); this.Items.Add("Cancelled"); } }After you have compiled the project, the StatusComboBox custom control will appear in the Toolbox. Below is the screen snapshot of the Toolbox:
Now, you may drag this control onto the Form and call "statusComboBox1.RefreshData()" to load the items.
No comments:
Post a Comment