处理datagrid控件中的复选框 [英] dealing with check boxes in datagrid control
问题描述
大家好
我正在开发学校申请.
有一个用于费用计算的表单,此表单包含一个DataGrid和一个Textbox控件.
数据将从databse填充到datagrid,将被查询,并且我必须在datagrid控件中为复选框添加更多一栏.
选中(部分或全部)复选框后,应计算课程的相关费用,并应在文本框中显示该费用.
我该怎么办..............?
这是Windows应用程序.
请帮助......
Hello All
I am developing an application for school.
There is a Form for Fees calculation, This Form contains one DataGrid and a Textbox control.
Data will be populated from databse to datagrid, which will be queried, and i have to add one more column for checkbox inside datagrid control.
After checking the (some or all) checkboxes the relevant fees of courses should be calculated and should be displayed inside textbox.
how can i do this.................??
it is windows application.
please help.........
推荐答案
确定已根据您的要求编辑了答案
http://www.syncfusion.com/FAQ/windowsforms/faq_c44c.aspx#q754q
Ok edited the answer as per your requirement
http://www.syncfusion.com/FAQ/windowsforms/faq_c44c.aspx#q754q
在相关位置的DataGridView中添加一个DataGridViewCheckBoxColumn.
在buttonCalucate_Click事件中..如下循环遍历所有行,并总计选定的行.
add a DataGridViewCheckBoxColumn to your DataGridView at relevant position.
in buttonCalucate_Click event.. loop through all the rows as follows and do total of the selected rows.
double dblTotal = 0.0;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
DataGridViewCheckBoxColumn colObj = row.Cells[0] as DataGridViewCheckBoxColumn ;
if (colObj.Selected)
{
dblTotal += convert.toDouble(row.Cells[1].Value.toString());
}
}
这篇关于处理datagrid控件中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!