如何检入datagridview单元格包含斜杠(/)我试过但它不工作显示错误 [英] how to check in datagridview cell contains a slash (/) i tried but it is not working shows the error
问题描述
注意它是Windows应用程序。
如何签入datagridview单元格包含一个斜杠(/)
我试过但它不是工作它显示错误
note it is windows application.
How to check in datagridview cell contains a Slash(/)
I tried but it is not working it show the error
for (int i = 0; i < datagridView.RowCount; i++)
{
for (int j = 2; j < datagridView.ColumnCount; j++)
{
if(datagridView[j,i].Value.ToString().Contains("/") = true)
{
sql = "insert into Tb_SCh_TIme_Table([Sch_Date], [Session], [Course],[Faculty_Code])" + " values ('" + Convert.ToDateTime(datagridView.Rows[i].Cells[0].Value.ToString()) + "', " + int.Parse(datagridView.Rows[i].Cells[1].Value.ToString()) + ", '" + datagridView[j, i].Value.ToString() + "','" + datagridView.Columns[j].HeaderText.ToString() + "')";
}
}
}
以下行显示错误
the below line shows error
if(datagridView[j,i].Value.ToString().Contains("/") = true)
错误信息如下;
作业的左侧必须是一个变量,属性或索引器。
i我在datagridview单元格中检查包含我编写上面代码的单元格,但显示我尝试过的错误但它不起作用。
。
我上面代码中的错误。
请帮帮我。
我怎么能用c sharp。
注意它是windows应用程序。
error message as follows;
The left-hand side of an assignment must be a variable, property or indexer.
i am checking in datagridview cell contains cell for that i written a above code, but shows a error i tried but it is not working.
.
what i the mistake in my above code.
please help me.
how can i do using c sharp.
note it is windows application.
推荐答案
改变你的if条件如下:
Change your if condition like below:
if(datagridView[j,i].Value.ToString().Contains("/") == true)
您在If条件中错过了==。
You have missed == in the If condition.
这篇关于如何检入datagridview单元格包含斜杠(/)我试过但它不工作显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!