Click to See Complete Forum and Search --> : owner-drawn controls


Trigve
November 1st, 2004, 07:38 AM
Hello,
I'm new in .NET architectrure and i want to ask how can i create owner-drawn ListView in C++? I'm programming with MFC and there i do that with DrawItem() and MeasureItem() methods.

thanks

Jinto
November 1st, 2004, 03:18 PM
Set the DrawMode property of the control to OwnerDrawFixed.

And use these to events.

DrawItem
MeasureItem

Eample of DrawItem.

System::Void comboBox1_DrawItem(System::Object * sender, System::Windows::Forms::DrawItemEventArgs * e)
{
e->DrawBackground();

StringFormat* sf = StringFormat::GenericDefault;
SolidBrush* brsh = new SolidBrush( Color::Blue );

e->Graphics->DrawString( comboBox1->Items->get_Item(e->Index)->ToString(), e->Font, brsh, RectangleF::op_Implicit( e->Bounds ), sf );
}

Trigve
November 2nd, 2004, 02:04 AM
Thanks,
but ListView class does not have property like DrawMode.