dataGridView[this.dataGridView.columns["日期"].index, 
                                                      this.dataGridView.Rows [i].index].value.Tostring()) 
不是一个实例吧,不能和text属性作比较吧

解决方案 »

  1.   

    index对应的是个值,而不是数据 
      

  2.   

    提供个算法: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;
    }临时想出来的,你试试把,代码可能有错,思路是这样的.
      

  3.   

    我在MSDN里找不到ToolStripTextBoxBase这个类,是不是ToolStripTextBox?
      

  4.   

     哈哈!谢谢各位了!我都给你们加分了!3楼的兄弟思路是对的
    只要把row=dataGridView1.SelectedRows[i];改为row=dataGridView1.Rows[i]就对了
    只是很奇怪string y=row.Cells["日期"].Value.ToString()这样就报错了“没有将对象引用设置到对象的实例”
    而如果强制转换string y=(String)row.Cells["日期"].Value就可以!