Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Using OwnerDraw in TElXTree

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.

imageimage

Is there any suggestions?

Comments

Sign In or Register to comment.