且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows应用程序中的DataGridview

更新时间:2023-10-14 13:31:10

DataGridView控件及其相关类被设计成一个灵活,可扩展的系统,用于显示和编辑表格数据。 DataGridView控件提供TextBox,CheckBox,Image,Button,ComboBox和Link列以及相应的单元格类型。在单元格中添加CheckBox时,可以通过程序代码显式设置单元格Value属性,该代码访问行的Cells集合中的单元格,也可以通过数据绑定进行设置。



以下C#代码显示如何在DataGridView控件的Cell中添加CheckBox,并将第三行复选框值设置为true。

The DataGridView control and its related classes are designed to be a flexible, extensible system for displaying and editing tabular data. The DataGridView control provides TextBox, CheckBox, Image, Button, ComboBox and Link columns with the corresponding cell types. While adding a CheckBox in a cell, the cell Value property can be set explicitly through programmatic code that accesses the cell in the Cells collection of the row, or it can be set through data binding.

The following C# code shows how to add a CheckBox in Cell of a DataGridView control and set the third row checkbox value as true.
DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
dataGridView1.Columns.Add(chk);
chk.HeaderText = "Check Data";
chk.Name = "chk";
dataGridView1.Rows[2].Cells[3].Value = true;





这显示了如何添加按钮;



And this shows how to add a button;

DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
dataGridView1.Columns.Add(btn);
btn.HeaderText = "Click Data";
btn.Text = "Click Here";
btn.Name = "btn";
btn.UseColumnTextForButtonValue = true;





祝你好运,

OI



Good luck,
OI


这些是给你的..

http://www.dotnetspider.com/resources/43689-How-create-check-box-column-datagridview.aspx [ ^ ]

http://csharp.net-informations.com/datagridview /csharp-datagridview-button.htm [ ^ ]
These are for you..
http://www.dotnetspider.com/resources/43689-How-create-check-box-column-datagridview.aspx[^]
http://csharp.net-informations.com/datagridview/csharp-datagridview-button.htm[^]


http://msdn.microsoft.com/ en-us / library / system.windows.forms.datagridviewbuttoncolumn.aspx [ ^ ]

http://social.msdn.microsoft.com/Forums/hr/winformsdatacontrols/thread/a8160578-baa4-4c2b-beb6-d44cbfb7fe2d [ ^ ]



和解决方案#1和#2也很好......祝你好运:)
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewbuttoncolumn.aspx[^]
http://social.msdn.microsoft.com/Forums/hr/winformsdatacontrols/thread/a8160578-baa4-4c2b-beb6-d44cbfb7fe2d[^]

and solution #1 and #2 is good as well... Good Luck :)