Hi,
I want to define style myself for certain cells. This is my code:
void TForm1::Inital()
{
ElXTree1->Items->BeginUpdate();
for(int i=0; i<ElXTree1->Items->Count; i++)
{
ElXTree1->Items->Item[i]->Cells->Cell[3]->UseOwnStyle = true;
ElXTree1->Items->Item[i]->Cells->Cell[3]->Style->DrawStyle = elhsOwnerDraw;
}
ElXTree1->Items->EndUpdate();
}
And I use OnCellDraw Event:
void __fastcall TForm1::ElXTree1CellDraw(TObject *ASender, TElXTreeCell *ACell, TCanvas *ACanvas, TRect &R)
{
if(ACell->HeaderSection->Index == 3)
{
ACanvas->Brush->Color = clYellow;
ACanvas->Font->Color = clRed;
}
ACanvas->TextRect(R, R.left, R.top, L"Test");
}
Generally, the Tree can be drawn normally, but When I set the style, the TextRect will be abnormal.
Is there any suggestions?
Comments