Mega Code Archive

 
Categories / Delphi / VCL
 

Dynamically delete TListView columns

Title: Dynamically delete TListView columns Question: If you've ever tried to delete a list view column at run time, you know it can't be done. Or can it? Answer: There is an undocumented Delphi function that allows you to just that. The command is declared in the CommCtrl.pas unit. Its declaration is shown here, function ListView_DeleteColumn(hwnd: HWND; iCol: Integer): Bool; where hwnd is the handle of your list view component and iCol is the index of the column you want to delete. Remember, the list view column index is zero based. Here's an example of calling the command: procedure TForm1.Button1Click(Sender: TObject); begin ListView_DeleteColumn(MyListView.Handle, 1); end;