主页 > 重庆成人高考 > 有谁有即按Item里的Data又按Item.Caption排序的ListV

有谁有即按Item里的Data又按Item.Caption排序的ListV

2020-04-24 07:10:03 作者:admin   |   浏览(197)

  以下代码有甚么毛病啊:(BCB)

  AnsiString Data1,Data2;

  if (ColumnsClick)

  {

  Data1=PMyData(Item1->Data)->NType;

  Data2=PMyData(Item2->Data)->NType;

  if (ColumnIndex==0)

  {

  if (Status[ColumnIndex])

  {

  Compare=CompareText(Data1,Data2);

  Compare=CompareText(Item1->Caption,Item2->Caption);

  ListView1->Columns->Items[0]->ImageIndex=2;

  ListView1->Columns->Items[1]->ImageIndex=-1;

  ListView1->Columns->Items[2]->ImageIndex=-1;

  ListView1->Columns->Items[3]->ImageIndex=-1;

  Status[ColumnIndex]=false;

  }

  else

  {

  Compare=CompareText(Data2,Data1);

  Compare=CompareText(Item2->Caption,Item1->Caption);

  ListView1->Columns->Items[0]->ImageIndex=3;

  ListView1->Columns->Items[1]->ImageIndex=-1;

  ListView1->Columns->Items[2]->ImageIndex=-1;

  ListView1->Columns->Items[3]->ImageIndex=-1;

  Status[ColumnIndex]=true;

  }

  }

  else

  {

  if (Status[ColumnIndex])

  {

  Compare=CompareText(Data1,Data2);

  Compare=CompareText(Item1->Caption,Item2->Caption);

  Status[ColumnIndex]=false;

  for (int x=0;x < ListView1->Columns->Count; x++)

  {

  if (x !=ColumnIndex)

  ListView1->Columns->Items[x]->ImageIndex=-1;

  else

  ListView1->Columns->Items[x]->ImageIndex=2;

  }

  }

  else

  {

  Compare=CompareText(Data2,Data1);

  Compare=CompareText(Item2->Caption,Item1->Caption);

  Status[ColumnIndex]=true;

  for (int x=0; xColumns->Count; x++)

  {

  if (x !=ColumnIndex)

  ListView1->Columns->Items[x]->ImageIndex=-1;

  else

  ListView1->Columns->Items[x]->ImageIndex=3;

  }

  }

  }

  ColumnsClick=false;

  }

  以上代码为在ListView1Compare工作中,可认为Compare两次赋值吗?但我一次两次

  后果确实纷歧样,有人有原码吗?

  该如何,能具体点吗?