Exercise - Control Models
Using the Solution Explorer open the Base Project and navigate to Shared.Theme.Controls Folder.
Right click on the Controls folder and add new item using the BaseControl template, name it MandatoryTextBox.
Open the Properties panel and set:
3.1. BackColor = LightCoral
3.2. Border = Thick
3.3. BorderColor = Red
Change the panel to show Events.
Double click the InputValidation event and show Error message if the this.Text == "";
Build the Base Project.
Open the ShowProducts.
Use Class Outline and navigate to the view.
Right Click the ToolBox and Add Tab name it My controls.
Right click anywhere on the form (Do not Right click a control like the grid on the form) and select Add Controls To Toolbox.
Navigate to the bin folder of your solution and select the NorthwindBase.dll.
In the new windows that open navigate to Northwind.Shared.Them.Controls and expend it.
select the MandatoryTextBox and click the Add to ToolBox button.
Drag and drop the MandatoryTextBox to the screen set the Data property to point to the Products.ProductName.
Replace the current textBox in the ProductName Column with the new MandatoryTextBox.
Save changes to Git.
Build and test , try to delete the product name from one of the rows in Runtime, and check that you get the error message.
Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com