G
g60sl22c
Unregistered / Unconfirmed
GUEST, unregistred user!
我用以下内容实现在单元格的值有变化时变色,dif存新值和旧值比较结果,0为无变,为蓝字白底,1为有变,为黑字红底.
void __fastcall TForm1::ValueListEditor2DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
if ((ARow>0)&&(ACol==1))
{
if (state->dif[ARow-1]==1)
{
ValueListEditor2->Canvas->Font->Color =clBlack;
ValueListEditor2->Canvas->Font->Name="黑体";
ValueListEditor2->Canvas->Brush->Color=clRed;
ValueListEditor2->Canvas->Brush->Style=bsSolid;
}
else
{
ValueListEditor2->Canvas->Font->Color=clBlue;
ValueListEditor2->Canvas->Font->Name="宋体";
ValueListEditor2->Canvas->Brush->Color=clWhite ;
ValueListEditor2->Canvas->Brush->Style=bsSolid;
}
ValueListEditor2->Canvas->Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
ValueListEditor2->Canvas->TextOut(Rect.Left+2,Rect.Top+2,ValueListEditor2->Cells[ACol][ARow]);
}
结果,数值有变时,颜色也变为黑字红底.但有时当数值无变,即dif数组全为0时,颜色还是黑字红底,而正常应为蓝字白底,我巳确定问题在这代码中,请高手指点
void __fastcall TForm1::ValueListEditor2DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
if ((ARow>0)&&(ACol==1))
{
if (state->dif[ARow-1]==1)
{
ValueListEditor2->Canvas->Font->Color =clBlack;
ValueListEditor2->Canvas->Font->Name="黑体";
ValueListEditor2->Canvas->Brush->Color=clRed;
ValueListEditor2->Canvas->Brush->Style=bsSolid;
}
else
{
ValueListEditor2->Canvas->Font->Color=clBlue;
ValueListEditor2->Canvas->Font->Name="宋体";
ValueListEditor2->Canvas->Brush->Color=clWhite ;
ValueListEditor2->Canvas->Brush->Style=bsSolid;
}
ValueListEditor2->Canvas->Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
ValueListEditor2->Canvas->TextOut(Rect.Left+2,Rect.Top+2,ValueListEditor2->Cells[ACol][ARow]);
}
结果,数值有变时,颜色也变为黑字红底.但有时当数值无变,即dif数组全为0时,颜色还是黑字红底,而正常应为蓝字白底,我巳确定问题在这代码中,请高手指点