Browse DevX
Sign up for e-mail newsletters from DevX


Building XML Applications with the .NET Framework 2.0 : Page 2

XML is the most popular technology for structuring data. .NET 2.0 provides much needed functionality to enable one to build XML-based applications. The enhanced DataTable now supports reading and writing XML data, which is crucial in creating XML-enabled applications.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Designing the Application UI
The application consists of two forms. The first allows a user to enter activity information and the second allows for entry of the various kinds of tasks.

Rename the default form in the application to frmDeskTimeKeeper. Drop a DataGridView control from the Toolbox on the form. Next you need to specify the datasource for the DataGridView control. Select the DataGridView control, on the upper right-hand side, select the SmartTag that appears and specify dsActivitiesTasks, which you have already created, as the datasource (see Figure 3). (Note: Select the dataset dsActivitiesTasks not the DataTables (activities or tasks).)

Figure 3. Adding a Datasource: In this dialog, specify the datasource for the DataGridView.
Figure 4. DataGridView DataSource: In this dialog, you will bind the DataGridView control directly to the DsActivitiesTasks dataset.

In the component tray you will notice that Visual Studio adds an instance of the dsActivitesTasks and also another component called dsActvitiesTasksBindingSource. You really don't need the Binding source—only the DataSet so that you can set the binding directly to the DataGridView control. You need to bind directly to the DataSet instance, so select the BindingSource and delete it.. Next reselect the SmartTag on the DataGridView control and specify its data source. You will notice that a new source is available, which is frmActivities List Instances. Below it you will find dsActivitiesTasks (see Figure 4), which you should select. In doing so you will bind the DataGridView control directly to the dsActivitiesTasks dataset.

Figure 5. Form Activities UI: In this dialog, you'll set the text for three buttons used by the application.
Next you need to set the DataMember property for the DataGridView to the activities DataTable. As you do this you will notice that the designer now shows the columns of the activities table on the DataGridView.

Customizing the DataGridView
The DataGridView shows all the columns of the activities DataTable. Some columns, such as the auto-generated activityid column, don't need to be displayed to the end user. Moreover, the taskid should ideally display the tasks instead of the IDs, and the user should be able to choose from the tasks DataTable. The taskid column would be better suited as a drop-down column, displaying the tasks, in order to simplify data entry.

You need to edit the properties of the columns in the DataGridView to achieve these effects. Select the SmartTag on the DataGridView control and choose Edit Columns. Set the properties as shown in Table 3:

Table 3. Setting Column Properties:

Column Property
activityid Visible=False
Taskid ColumnType= DataGridViewComboBoxColumn
DataSource= DsActivitiesTasks
DataMember= tasks.task
description Width=180

After customizing the DataGridView the next step is adding three buttons to the form. Name them btnEditAddTasks, btnSave, and btnDelete, and set their text property as shown in Figure 5. Then resize the form appropriately.

Thanks for your registration, follow us on our social networks to keep up-to-date