for (int I=0; I & lt; DataGridView1. Columns. The Count; I++)
{
This. DataGridView1. Columns [I] SortMode=DataGridViewColumnSortMode. NotSortable;
}
for (int i=0; I & lt; DataGridView1. Rows. The Count - 1; I++)
{
DataGridView1. ClearSelection ();
String sqlX=string. The Empty;
SqlX +="SELECT the enable the FROM XITEM WHERE LEFT (HOKAN, 2)='BS' and code='" + dataGridView1. Rows [I] Cells [r]." project code "Value. The ToString () +"' ";
String SQL=Program. SqlCommandExecuteScalarReturnString1 (sqlX);
{
If (SQL=="0")
{
DataGridView1. Rows [I]. DefaultCellStyle. BackColor=Color. LightGray;
DataGridView1. ClipboardCopyMode=DataGridViewClipboardCopyMode. Disable;
}
}
}
Now want to control the background color of the query from a forbidding grey data, other data can be copied
Add the
DataGridView1. ClipboardCopyMode=DataGridViewClipboardCopyMode. Disable;
This code later whether or not meet the conditions of forbidding, how to change
CodePudding user response:
In selectionchange judgment, if contain banned cell were not allowed to copy,