本文介绍了Datagridview和复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个datagridview,我的日期来自acces数据库
void AfisareProduseContract()
{
Program.Connection.CommandText = " 从ContractItems中选择* WHERE ContractId = @ ContractId" ;
Program.Connection.AddParameter(" @ ContractId" ,Convert.ToInt32(IdContractEditare));
DataTable Table = 新 DataTable();
Program.Connection.FillDataTable(Table, true );
for ( int i = 0 ; i < Table.Rows.Count; i ++)
{
如果(字符串 .IsNullOrWhiteSpace(Table.Rows [i] [" DeletedId" ].ToString()))
{
dataProduseContract.Rows.Add(Table.Rows [i] [" 名称" ].ToString(), Table.Rows [i] [" 数量" ].ToString()+ " " + Table.Rows [i] [" QuantityUnit"].ToString(),Table.Rows [i] [" 付款" ].ToString(),Table.Rows [i] [" 描述" ].ToString());
}
}
}
我希望为每个单元格(如果有ROW)提供一个复选框,并且如果数据库中的该行为空,则该复选框可单击,如果不为空,则datagridview中的行将处于非活动状态.
I have a datagridview, and my date in from acces database
void AfisareProduseContract()
{
Program.Connection.CommandText = "select * from ContractItems WHERE ContractId=@ContractId";
Program.Connection.AddParameter("@ContractId", Convert.ToInt32(IdContractEditare));
DataTable Table = new DataTable();
Program.Connection.FillDataTable(Table, true);
for (int i = 0; i < Table.Rows.Count; i++)
{
if (String.IsNullOrWhiteSpace(Table.Rows[i]["DeletedId"].ToString()))
{
dataProduseContract.Rows.Add(Table.Rows[i]["Name"].ToString(), Table.Rows[i]["Quantity"].ToString() + " " + Table.Rows[i]["QuantityUnit"].ToString(), Table.Rows[i]["Payment"].ToString(), Table.Rows[i]["Description"].ToString());
}
}
}
I whant to have a checkbox for every cell if the ROW, and if that row in the database is empty the checkbox to be clickable, if is not empty the row in datagridview to be inactive.
解决方案
这篇关于Datagridview和复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!