| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 29283 人关注过本帖, 10 人收藏
标题:个人珍藏DataGridView控件秘籍
取消只看楼主 加入收藏
wangnannan
Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18
等 级:贵宾
威 望:87
帖 子:2546
专家分:9359
注 册:2007-11-3
结帖率:80.91%
收藏(10)
 问题点数:0 回复次数:0 
个人珍藏DataGridView控件秘籍
个人珍藏DataGridView控件秘籍 千万不要跟别人说你已经完全掌握了DataGridView 至少也得看完这本书在说  呵呵  希望对大家有帮助 目录如下
程序代码:
DataGridView控件
DataGridView是用于Windows Froms 2.0的新网格控件。它可以取代先前版本中DataGrid控件,它易于使用并高度可定制,支持很多我们的用户需要的特性。 

关于本文档:
本文档不准备面面俱到地介绍DataGridView,而是着眼于深入地介绍一些技术点的高级特性。

本文档按逻辑分为5个章节,首先是结构和特性的概览,其次是内置的列/单元格类型的介绍,再次是数据操作相关的内容,然后是主要特性的综述,最后是最佳实践。

大部分章节含有一个“Q & A”部分,来回答该章节相关的一些常见问题。注意,某些问题会由于知识点的关联性重复出现在多个章节。这些问题、答案及其附带的示例代码都包含在本文档的附录部分。

注意:本文档的大部分内容来自MSDN中DataGridView控件的相关文档。

内容
1    何为DataGridView    4
1.1    DataGridView和DataGrid 之间的区别    4
1.2    DataGridView的亮点    5
2    DataGridView的结构    6
2.1    结构元素    6
2.2    单元格和组    6
2.3    DataGridView的单元格    6
2.3.1    DataGridViewCell的工作机制    7
2.4    DataGridView的列    9
2.5    DataGridView的编辑控件    9
2.6    DataGridView的行    10
3    列/单元格类型揭密    11
3.1    DataGridViewTextBoxColumn    11
3.2    DataGridViewCheckBoxColumn    12
3.3    DataGridViewImageColumn    12
3.4    DataGridViewButtonColumn    13
3.5    DataGridViewComboBoxColumn    13
3.5.1    DataError与ComboBox列    13
3.6    DataGridViewLinkColumn    14
4    操作数据    15
4.1    数据输入和验证的相关事件    15
4.1.1    数据验证相关事件的顺序    15
4.1.2    验证数据    15
4.1.3    在新行中的数据输入    16
4.2    关于Null值    19
4.2.1    NullValue属性    19
4.2.2    DataSourceNullValue属性    19
4.3    DataError事件    20
4.4    数据绑定模式    21
4.4.1    非绑定模式    21
4.4.2    绑定模式    21
4.4.3    虚拟模式    22
4.4.4    混合模式    22
5    Overview of features    24
5.1    Styling    24
5.1.1    The DataGridViewCellStyle Class    24
5.1.2    Using DataGridViewCellStyle Objects    24
5.1.3    Style Inheritance    25
5.1.4    Setting Styles Dynamically    28
5.2    Custom painting    28
5.2.1    Paint Parts    28
5.2.2    Row Pre Paint and Post Paint    29
5.3    Autosizing    30
5.3.1    Sizing Options in the Windows Forms DataGridView Control    30
5.3.2    Resizing with the Mouse    31
5.3.3    Automatic Sizing    32
5.3.4    Programmatic Resizing    33
5.3.5    Customizing Content-based Sizing Behavior    34
5.3.6    Content-based Sizing Options    34
5.4    Selection modes    34
5.4.1    Programmatic Selection    35
5.5    Scrolling    35
5.5.1    Scroll event    35
5.5.2    Scroll bars    35
5.5.3    Scrolling Properties    36
5.6    Sorting    36
5.6.1    Programmatic Sorting    37
5.6.2    Custom Sorting    38
5.7    Border styles    39
5.7.1    Standard Border Styles    39
5.7.2    Advanced Border Styles    39
5.8    Enter-Edit modes    40
5.9    Clipboard copy modes    40
5.10    Frozen columns/rows    41
5.11    Implementing Custom cells and editing controls/cells    41
5.11.1    IDataGridViewEditingControl    42
5.11.2    IDataGridViewEditingCell    42
5.12    Virtual mode    42
5.12.1    Bound Mode and Virtual Mode    42
5.12.2    Supplementing Bound Mode    42
5.12.3    Replacing Bound Mode    43
5.12.4    Virtual-Mode Events    43
5.12.5    Best Practices in Virtual Mode    44
5.13    Capacity    44
6    Best Practices    45
6.1    Using Cell Styles Efficiently    45
6.2    Using Shortcut Menus Efficiently    45
6.3    Using Automatic Resizing Efficiently    45
6.4    Using the Selected Cells, Rows, and Columns Collections Efficiently    46
6.5    Using Shared Rows    46
6.6    Preventing Rows from Becoming Unshared    47
附录 A – 常见问题:    49
1.    如何使指定的单元格不可编辑?    49
2.    如何让一个单元格不可用?    49
3.    如何避免用户将焦点设置到指定的单元格?    51
4.    如何使所有单元格总是显示控件(不论它是否处于编辑状态)?    51
5.    Why does the cell text show up with “square” characters where they should be new lines?    51
6.    如何在单元格内同时显示图标和文本?    51
7.    如何隐藏一列?    53
8.    如何避免用户对列排序?    53
9.    如何针对多个列排序?    54
10.    如何为编辑控件添加事件处理函数?    58
11.    应在何时移除编辑控件的事件处理函数?    58
12.    如何处理ComboBox列中ComboBox控件的SelectIndexChanged事件?    58
13.    如何通过拖放调整行的顺序?    59
14.    如何调整最后一列的宽度使其占据网格的剩余客户区?    60
15.    如何让TextBox类型的单元格支持换行?    60
16.    如何使Image列不显示任何图像(字段值为null时)?    61
17.    如何能够在ComboBox类型的单元格中输入数据?    61
18.    How do I have a combo box column display a sub set of data based upon the value of a different combo box column?    61
19.    如何在用户编辑控件的时候(而不是在验证时)就显示错误图标?    62
20.    如何同时显示绑定数据和非绑定数据?    65
21.    How do I show data that comes from two tables?    66
22.    如何显示主从表?    66
23.    如何在同一DataGridView中显示主从表?    68
24.    如何避免用户对列排序?    68
25.    如何在点击工具栏按钮的时候将数据提交到数据库?    68
26.    如何在用户删除记录时显示确认对话框?    68

图片附件: 游客没有浏览图片的权限,请 登录注册

图片附件: 游客没有浏览图片的权限,请 登录注册

原书为word 文件
DataGridView控件.rar (354.39 KB)

搜索更多相关主题的帖子: 秘籍 DataGridView 控件 珍藏 
2010-11-01 13:23
快速回复:个人珍藏DataGridView控件秘籍
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018982 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved