DataGridView根据条件查找数据行 dataGridView[this.dataGridView.columns["日期"].index, this.dataGridView.Rows [i].index].value.Tostring()) 不是一个实例吧,不能和text属性作比较吧 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 index对应的是个值,而不是数据 提供个算法:string x=toolStripTextBoxBase1.TextBox.Text;//先把你输入的数据存到X变量中DataGridViewRow row=new DataGridViewRow();for(int i=0;this.dataGridView.Rows.count;i++){ row=dataGridView1.SelectedRows[i];//一行行遍历 string y=row.Cells["日期"].Value.ToString();//取出表中的数据 if(x==y) {this.dataGridView.Rows[i].defaultCellStyle.backColor=Color.Blue} break;}临时想出来的,你试试把,代码可能有错,思路是这样的. 我在MSDN里找不到ToolStripTextBoxBase这个类,是不是ToolStripTextBox? 哈哈!谢谢各位了!我都给你们加分了!3楼的兄弟思路是对的只要把row=dataGridView1.SelectedRows[i];改为row=dataGridView1.Rows[i]就对了只是很奇怪string y=row.Cells["日期"].Value.ToString()这样就报错了“没有将对象引用设置到对象的实例”而如果强制转换string y=(String)row.Cells["日期"].Value就可以! 有没有DES算法,附加条件是每次得出的结果要不一致 如何刷新bitmap 我做了个工具连接的是Sqlserver现在想运用多种数据库比如oracle,mysql改如何修改? c#如何实现点击button实现打开一个webbrower并且webbrower中的url等于当前窗体的某个textbox值 文件保存的问题 jmail发邮件失败,救命! InstallShield打包相关问题 数据库与应用服务安装在同一台服务器上好吗?哪位能推荐一下HP的服务器型号以及配置,谢谢! C# 链表问题 解决马上给分,在线等! 绑定新闻 怎么弄 快来看看!
DataGridViewRow row=new DataGridViewRow();
for(int i=0;this.dataGridView.Rows.count;i++)
{
row=dataGridView1.SelectedRows[i];//一行行遍历
string y=row.Cells["日期"].Value.ToString();//取出表中的数据
if(x==y)
{this.dataGridView.Rows[i].defaultCellStyle.backColor=Color.Blue}
break;
}临时想出来的,你试试把,代码可能有错,思路是这样的.
只要把row=dataGridView1.SelectedRows[i];改为row=dataGridView1.Rows[i]就对了
只是很奇怪string y=row.Cells["日期"].Value.ToString()这样就报错了“没有将对象引用设置到对象的实例”
而如果强制转换string y=(String)row.Cells["日期"].Value就可以!