Detailed description of how to use the FarPoint Spread table control to construct the Winform Excel table interface input, farpoint Table Control

Source: Internet
Author: User

Detailed description of how to use the FarPoint Spread table control to construct the Winform Excel table interface input, farpoint Table Control

Let's take a brief look at WinForm and FarPoint. WinForm is a title for Windows Form on the Net development platform. FarPoint is a EXCEL simulation control. Most EXCEL operations can be performed according to user requirements, including multiple sub-tables, table style definitions, formula calculation, sorting, and grouping. This article describes how to use the FarPoint Spread table control to construct the Winform Excel table interface input.

On the Winform interface, enter relevant data similar to the Excel table interface. On the interface, you need to enter image information, basic information, and list information. The following figure shows the effect of the interface. This article focuses on how to use the FarPoint Spread table control to save and display rich data similar to the Excel interface, we also hope that some experience in the use process will be helpful for the development of Winform Excel data input and display.

According to the preceding interface classification, we can see that the data types on this interface are basic field data, multi-row list data, image data, and note information display input. Next we will introduce how to implement these functions by category.

1. Overall list interface design similar to Excel

First, drag a Farpoint control to the Winform interface in this list, set the layout and other attributes, and then start Spread Designer on the right-click menu, in this way, you can design the relevant Excel Style Sheet content.

Note: Generally, this interface is designed in a form. Of course, you can copy and paste your content from an Excel file, if the effect is the same. However, although the Farpoint Spread control provides an operation to save a file as an Xml file and Open an XML file through APIS, it seems that the content cannot be modified after an Open XML file, in addition, the CellType type is also Null, so it is impossible to dynamically load the layout on a form. But for development, we designed the Excel Style list interface during design, which is also a good choice.

2. Bind the drop-down list

In most cases, for the convenience of input, we will choose to input content in the Excel list through the drop-down list, so as to improve the speed and user experience, however, the content must be bound through the database content. The Farpoint Spread control binds data from the drop-down list by inputting a lot of content and including ComoBox data. As shown below.

When the drop-down type is specified, the display mode of the Excel list changes, for example, as shown below.

The above check box shows the list of List data to be bound next. It is not difficult to bind the list data, but you need to specify the Cell serial number and bind it to the data source, in fact, it is very effort-consuming and inconvenient to count the numbers on the Cell's row and column numbers.

For the BindDictItems code, I used the extension method, so we can directly call this method through the object. The specific function code is as follows: This is to call the dictionary service class to obtain data, however, you need to assign values to the Items attribute. It is best to set Edittable to true. Otherwise, it will only display the content of the list in the DropdownList.

3. How to create custom input on the Interface

To facilitate content input, you can select content in the pop-up box, edit the image, and edit the remarks (For A Long Time, we usually use a custom interface to enter a relatively good Excel-style interface. The input cells are very small and sometimes cannot be achieved. Therefore, the Click Event of the control cell is used to process special input information operations.

The following shows some content of the interface, as shown below:

For example, for the drop-down list content, we need to make a pop-up selection, as shown in the following interface.

For image cells, you can click to pop up the following form for easy editing or viewing.

For the remarks, let him pop up a form for better display and editing.

4. data display and storage

It is very simple to display common data fields in the primary table. You just need to assign the content to the Text attribute of the corresponding cell, as shown below.

When we need to save the content, we just need to save the corresponding content to the object class for data saving.

However, when there is a large amount of data, we need to save the content separately. Each function is responsible for different parts. After the master table is saved, we can continue to save the content of other parts, for example, the red part is the save operation of other parts.

For example, a process is a list of data. When we save the process, we need to specify the attribute of the row and column for operation, and we add a sequence number of Seq, which is used to save the order of the content, in this way, we load and display the data in sequence. Otherwise, problems may occur.

Here, the GetProcess function is used to find the corresponding ordered content in the list. If so, we need to update the corresponding ordered content; otherwise, we will regard it as new data, in this way, it is added to the database, so InserUpdate is used in the end. The logic code of the GetProcess function is as follows.

Note that some cells merge columns. Therefore, you must note the row and column numbers, because in some cases, you may need to skip rows.

5. Print and export data in an Excel table.

For the space using Farpoint Spread, it is very convenient to print or export the content in Excel. The important thing is that the Code is not cumbersome, as shown below.

The exported results are basically the same as those displayed on the interface. In addition, images and other special formats are normally stored in Excel, which is quite good in the sense.

In the end, we will attach some of this system as a supplement.

At this point, we have basically finished introducing the input content of using the FarPoint Spread table control to construct the Winform Excel table interface. We have introduced the content in five sections above, the first is the basic content of the overall interface design similar to Excel, the second is the binding of the drop-down list, the third is how to construct custom interface input, and the fourth is data display and storage, 5. Print and export data in an Excel table.

Related Article

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.