Dynamic ListView RRS feed

  • Question


    Hi I am using C++/CLI in VC 2008..

    I want to create a dynamic ListView which changes ColumnHeaders (adds or deletes) as I call various methods..

    How to do that??

    The Column Headers are added in the beginning of the windows generated code and then when I want to add it again(using gcnew), it throws error (obviously it would)..

    Can anyone suggest me a workaround??

    Tuesday, April 22, 2008 10:57 AM


  • Hi,


    Would you please post a snippet code and error message in order to find the error cause?


    By the way, to add a column to the ListView control, just call the Add method of



    Here is sample code, hope it helps!

    Code Snippet

    public ref class Form1 : public System::Windows::Forms::Form


    //…other codes



    //define ListView varaible

    private: System::Windows::Forms::ListView ^lstView;


    private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e)


                       //Create the ListView control    

                       this->lstView=gcnew System::Windows::Forms::ListView();

                      //Set its properties

                       this->lstView->Size=System::Drawing::Size(300, 200);




                       //Add columns





    private: System::Void btnAdd_Click(System::Object^  sender, System::EventArgs^  e)


                       //Add columns






    For detail information of ListView, you can refer to


    Hope it helps!


    Thursday, April 24, 2008 8:55 AM