Multirow discovery journey (4)-use multirow to develop winform applications (with source code)

Source: Internet
Author: User
Previous review

MultiRow discovery Tour (1)-efficient template designer

MultiRow discovery Tour (2)-Detailed description of the property manager

MultiRow discovery Tour (3)-template manager and Table

 

The goal of this article is to quickly develop a simple WinForm database application-"employee information management system" Through MultiRow ". The built-in Cell type, MultiRow template creation, and MulitRow printing functions provided by MulitRow are used.

Prepare Database

First, we use the Microsoft Access 2007 database to create a data table named Employees, create some fields, and specify the data type for each field. See:

After the field data type and name are determined, switch to DataSheet View mode and enter the data, as shown in:

When a traditional table control displays a record in a data table, most of the records are displayed in an independent row in the table control. The columns in each row correspond to one column in the data table, for example. the DataGridView control provided by the. net framework. It is bound to data, as shown in:

The database created above has 19 fields. If the DataGridView is used for display, the application will need a wider distance to completely display a record. This reduces readability. Therefore, a data table record can be freely laid out, enhancing readability and aesthetics is one of the ways in which table controls keep moving forward.

With MulitRow, you can arrange the positions of each Cell on a Row of MulitRow as you like, or even overlay multiple cells, each Cell is used to display each data field in a data table record. In this case, you need to open Visual Studio, create a Windows Forms Application project, and add a MultiRow Template ), for how to add a template and use the integrated template designer provided by MulitRow, refer to the previous three articles.

Edit Template

When creating a template, We need to select different Cell types based on different field types in the database to display data.

In this example, I only use nine Cell types and set the following layout based on my preferences:

All cells are arranged in the Row area of the template. After the template is loaded to the GcMultiRow control, the Row iterates based on the number of data records. In addition, I select different Cell types to display data based on different data domain types.

· The background is SystemColors. the Control Cell is RowHeaderCell, which is used to describe the subsequent data type Cell. Like a label, it can have Hover, click, and other effects, and can also select and display row numbers;

· You can use CheckBoxCell to display boolean data;

· "Phone number", "zip code", and "monthly salary" have fixed formats. You can use MaskedTextBoxCell to display them, and set its Mask attribute to control the display format;

· The DateTimePicker type can be used for date types;

· ImageCell can be used for image types.

MulitRow provides up to 23 Cell types, you can choose a different Cell type to display data, here is not detailed introduction, can refer to the http://www.grapecity.cn/powertools/products/mr_features.htm

After the Cell is placed, You need to associate each data Cell with the fields in the data table so that the Cell will display the values in a specific data column after running. You can use the TemplateProperty manager or property manager provided by the MultiRow template designer to set the DataField attribute of each data Cell and associate it with the column name of the data table. After the template is loaded, each data Cell can display the corresponding columns in the data table.

If you think the Style of the Template is too monotonous, you can adjust the Style attribute in the Template to set the appearance. For details, refer to the "how to set Style and skin" section in the MulitRow help document. I have designed a style, as shown in: (just give a picture. If you feel ugly, please forgive me ~)

Application Template

After completing the above work, a basic template is designed. The rest of the work is to apply the Template to a GcMultiRow control. We add a GcMultiRow control on Form, set the designed Template to its Template attribute, add a data source to the GcMultiRow control, and set some attributes.

Complete the application

Finally, two ToolStrip can be added to Form to display navigation and printing functions. Then run the project. The effect is as follows:

You can click the button at the bottom of the Form to switch between the previous record and the next record, and preview the print effect using the button at the top of the Form.

It is worth mentioning that the above application only shows a Row in the GcMultiRow control, that is, a record in the data table, I adjusted the Form size to the same size as a Row, so I can browse a Row each time. By clicking the button on the navigation bar, I can use the Row-based scrolling effect provided by GcMultiRow, it looks like a piece of browsing. At this time, if you increase the Form height, you will see multiple rows exist on the Form, just like a card, please refer:

You can also maintain that there is only one Row in the Form, no matter how it is scaled down. This requires several lines of code. I will not demonstrate it here. If you are interested, you can access the MulitRow area of GCDN, we can discuss some details together.

Preview and print

MultiRow also provides the printing function and various printing modes and settings. The SingleRow printing mode is used below to ensure that only one record is printed on each page. The print preview effect is as follows:

If you are satisfied, print it directly ~

 

Source code download:

SourceCode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.