Henry notes-winform The DataGrid structure (i)-windows Development-.net Tutorial-

Source: Internet
Author: User
Henry notes the analysis of the structure of-winform DataGrid (i)
Han Rui (2002-11-14)

Have long wanted to write this topic, but have been wondering whether the DataGrid in the WinForm of. NET has been able to perform a comprehensive analysis. But more and more people are asking questions lately, One is the use of. NET programmers in the increase, and secondly is that the use of the DataGrid has been out of the original display data requirements, want to make a high-level use, you should have a full understanding of the structure of the DataGrid, this article hopes to have the needs of the friends a little help.
I. BASIC structure
In shape, a DataGrid is made up of multiple tables (table), which consist of rows and columns (column), and rows and columns that are composed of cells (cell). Our need is to be able to control the changes in each cell, so that the row and column changes, resulting in a table changes. Each of these changes can be considered a stylistic format (style) for a table in the DataGrid.
After we deploy the DataGrid control to the form, the autoformat appears below its Properties window, which changes mostly in the background color (BackColor) and the foreground color (Forecolor) and fonts (font). After the story of this article, you will be able to achieve more formatting changes.
To describe the basic structure, first look at Figure 1:

However, the DataGrid does not directly write data, and the data shown in Figure 1 is determined by the DataSource (data source) of the DataGrid. This datasource is an object that supports IEnumerable interfaces, such as Arraylist, Collection, Dataview, Datarow, DataTable, and so on. (This issue is not the focus of this article, temporarily skipped)
So what exactly is the structure of the DataGrid? I tried to draw a structure diagram as shown in Figure 2:
As a clear view, we mainly discuss the Datagrid->datagridtablestyle->datagridcolumnstyle. We normally see the default structure DataGrid, which is to set the DataGridColumnStyle as a datagridtextboxcolumn column structure, and set the DataGrid column to consist of a TextBox. So we can see the effect shown in Figure 1, each cell is a textbox. By the same token, we know that if you set the DataGridColumnStyle of a column to a DATAGRIDBOOLCOLUMN column structure, you can display and change the Boolean value in that column with a CheckBox control. We can even customize the column type of a column, join the Combox and so on, this content in later text will be detailed.
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.