Home > Net >  Datagridview control error after use prohibited sorting statements
Datagridview control error after use prohibited sorting statements

Time:03-12

I novice, just contact with c # 3 months
Have such a piece of code
for (int i=0; I & lt; DataGridView1. Rows. The Count - 1; I++)
{
DataGridView1. ClearSelection ();
DataGridView1. ClipboardCopyMode=DataGridViewClipboardCopyMode. Disable;
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;
}


}
}

When I was in the form item coding input the correct project code is not an error, the following error when the input fuzzy query such as 180 times


Insert ban sort statement because a datagridview interface click sort, query time before background to meet the conditions of gray data don't display gray, how do I solve

CodePudding user response:

Write very clear, access to cross a line and Column [I], what is the I here, debugging and have a look

CodePudding user response:

Problems have been found, have banned the sort is added into the circulation, added to do statement
for (int i=0; I & lt; DataGridView1. Columns. The Count; I++)
{
This. DataGridView1. Columns [I] SortMode=DataGridViewColumnSortMode. NotSortable;
}
  •  Tags:  
  • C#
  • Related