Custom control Gridboxcard Use instance description in the Open Source EFW framework Framework

Source: Internet
Author: User
Tags wubi

Back to the "open source" EFW Framework Series article index

EFW Framework Source code Download V1.3:http://pan.baidu.com/s/1c0dado0

EFW Framework Instance source code download: Http://pan.baidu.com/s/1eQCc69G

The powerful custom controls in the EFW framework and the API descriptions for each control are listed in the custom controls for EFW framework WinForm front-end development, but it is not clear how these controls are used, but the way in which the Gridboxcard controls are used is explained in detail in this chapter.

This article highlights:

1. Example function description

2. Control property settings

3. Writing Background code

1. Example function Description

Make a book in the grid, click on the "New" button grid added blank lines, focus on the book Name column, and pop-up drop-down book directory, you can filter the book by Pinyin Wubi code, enter the selected books to add to the grid, and then select the next book, so in the grid generated a custom book list.

2. Control property Settings

1) Drag the Gridboxcard control in the toolbar into the form and set the column for the grid, where the ReadOnly property is False, the readonly of the book Name column in the Columns property is set to False, and the other columns are set to true;

2) Set some custom properties of the Gridboxcard control, especially the Selectioncards property, click Add a member, if there are more than one column need to tie down the grid, then here to add a number of members, here only need to "book name" this column binding grid;

3) You need to set the properties of the Datagridviewselectioncard member, where Bindcolumnindex is the column index, and the index of the "book Name" column is 1, so this is set to 1. Where the Cardcolumn property specifies the column "code| encoded |50,name| name |auto" displayed in the drop-down grid means that two columns of "encoding" and "name" are displayed. Where the Queryfieldsstring property specifies that the column name "NAME,PYM,WBM" of the filtered grid data indicates that the book can be filtered by name, phonetic code, Wubi code three fields;

3. Writing Background Code

1) Building a data source "book dictionary"

 //Data Source        PrivateDataTable GetData () {DataTable dt=NewDataTable (); Dt. Columns.Add ("Code"); Dt. Columns.Add ("name"); Dt. Columns.Add ("Pym"); Dt. Columns.Add ("WBM"); Dt. Columns.Add (" Price"); Dt. Columns.Add ("buydate"); Dt. Rows.Add (" on","Human Moon Myth","Rysh","Rysh","12.00","2014-02-21"); Dt. Rows.Add (" Geneva","the peak of the Tide","Lczd","Lczd","12.00","2014-03-11"); Dt. Rows.Add ("Geneva","person pieces","RJ","RJ","12.00","2014-08-01"); Dt. Rows.Add ("Geneva","Object-oriented design","MXDXSJ","MXDXSJ","12.00","2014-12-01"); Dt. Rows.Add (" to","the beauty of architecture","Jgzm","Jzzm","12.00","2014-12-21"); Dt. Rows.Add (" .","Original Design","Sjyb","Sjyb","12.00","2014-05-21"); Dt. Rows.Add (" -","Agile Project Management","MJXMGL","MJXMGL","12.00","2014-01-11"); Dt. Rows.Add (" ,","The beauty of code","DMZM","DMZM","12.00","2014-04-21"); Dt. Rows.Add (" the","Boulevard to Jane","Dzzj","Ddzj","12.00","2014-01-01"); Dt. Rows.Add ("Ten","out of the software workshop","Zcrjzh","Zcfjzh","22.00","2014-02-11"); returnDT; }

2) The control binds the data source, respectively, to the control's datasource and the drop-down grid bound data source for the control column

Private void Form1_Load (object  sender, EventArgs e)        {            = GetData (). Clone ();             // binding Data Sources            Gridboxcard1.datasource = dtsource;             // binding a grid data source            Gridboxcard1.bindselectioncarddatasource (0, GetData (). Copy ());        }

3) Click "Add" to start editing grid data

// New        Private void button1_click (object  sender, EventArgs e)        {            gridboxcard1.addrow ();        }

4) Select the drop-down grid data to assign to the grid control

//Select Grid row, data assignment        Private voidGridboxcard1_selectcardrowselected (ObjectSelectedValue,ref BOOLStopref intCustomnextcolumnindex) {DataTable dt= (DataTable) This. Gridboxcard1.datasource; introwindex =GridBoxCard1.CurrentCell.RowIndex; Dt. rows[rowindex]["Code"] = ((DataRow) selectedvalue) ["Code"]; Dt. rows[rowindex]["name"] = ((DataRow) selectedvalue) ["name"]; Dt. rows[rowindex][" Price"] = ((DataRow) selectedvalue) [" Price"]; Dt. rows[rowindex]["buydate"] = ((DataRow) selectedvalue) ["buydate"]; }

Summary: This control is suitable for the function of editing data directly in the grid, the bottom grid data source dictionary data, so that the user is very intuitive to operate, the control simplifies the control of the grid operation of the code, especially the column binding grid does not require too much code, just set a few properties on the line;

Custom control Gridboxcard Use instance description in the Open Source EFW framework Framework

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.