关于Datagridview下拉框赋初值问题 现在已经绑定了Dgv的下拉框,但是只能去选择,没有找去赋初值的属性,而且也没有SELECT方面的属性,只有一个BOOL型的selected,也没有帮助,请问怎么给其赋值初值(从数据库查出),用哪个属性区获取我所选的值,然后进行保存(数据库的改写),谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DataTable dt= (new CostManage.BLL.bas_DataImportModel()).GetAllListSystemTable().Tables[0];DataGridViewComboBoxCell dgcombo = (DataGridViewComboBoxCell)dgMain.Rows[i].Cells[5];dgcombo.DataSource = dt;dgcombo.DisplayMember = "TableEnglishName";dgcombo.ValueMember = "TableChineseName";if (dgcombo.Value == null){ if (dt.Rows.Count > 0) { dgcombo.Value = dt.Rows[0]["TableChineseName"].ToString(); //默认第一条记录 }} for(int i=0;i<datagridview1.rows.count;i++){ if(datagridview1.Rows[i].Cells[0].Value != null)//假如你的0列一定会有值 { if(datagridview1.Rows[i].Cells[列号].Value == null) { datagridview1.Rows[i].Cells[列号].Value = ds.Tables[0].Rows[0]["名称"].ToString(); } else if(datagridview1.Rows[i].Cells[列号].Value == "") { datagridview1.Rows[i].Cells[列号].Value = ds.Tables[0].Rows[0]["名称"].ToString(); } }}个人觉得判断后科学点 楼上的,这个方法我之前就试过了,会有问题,在把DS中的表的某个值赋到CBO的时候会出现datagridviewcombocell异常错误. C#中窗体隐藏 textbox修改过内容但text属性不变 一个简单的问题 这段代码该如何优化呢 ? 一个小问题,解决就给分 如何编写代码控制在一个应用程序中触发一个新的应用程序?? 不显示删除回复显示所有回复显示星级回复显示得分回复 关于DATAGRID 和DATAGRIDVIEW 分页的困惑,请各位指点下 asp.net如何调用word编辑器? 请教关于访问ArrayList中元素的问题 SqlConnection这样的初始化有什么不同。有什么优缸点? 串口控制MODEM拨号不能检测到载波的问题,请教高手 C#如何获取指定目录的最新的一个文件?
DataTable dt= (new CostManage.BLL.bas_DataImportModel()).GetAllListSystemTable().Tables[0];
DataGridViewComboBoxCell dgcombo = (DataGridViewComboBoxCell)dgMain.Rows[i].Cells[5];
dgcombo.DataSource = dt;
dgcombo.DisplayMember = "TableEnglishName";
dgcombo.ValueMember = "TableChineseName";
if (dgcombo.Value == null)
{
if (dt.Rows.Count > 0)
{
dgcombo.Value = dt.Rows[0]["TableChineseName"].ToString(); //默认第一条记录
}
}
for(int i=0;i<datagridview1.rows.count;i++)
{
if(datagridview1.Rows[i].Cells[0].Value != null)//假如你的0列一定会有值
{
if(datagridview1.Rows[i].Cells[列号].Value == null)
{
datagridview1.Rows[i].Cells[列号].Value = ds.Tables[0].Rows[0]["名称"].ToString();
}
else if(datagridview1.Rows[i].Cells[列号].Value == "")
{
datagridview1.Rows[i].Cells[列号].Value = ds.Tables[0].Rows[0]["名称"].ToString();
}
}
}
个人觉得判断后科学点