title: How to extend a listbox in VC++
body: <p>I tried to extend a listbox by adding a couple functions. I get an error ( error C2144: syntax error : 'Extended_ListBox' should be preceded by ':'). Would anyone please teach me how to fix it? I went to the line which VC++ said there was the error, but I had no clue why the constructor had an error.</p>
  
  <pre><code>    using namespace System;
  using namespace System::ComponentModel;
  using namespace System::Collections;
  using namespace System::Windows::Forms;
  using namespace System::Data;
  using namespace System::Drawing;
  using namespace System::Collections;
  using namespace System::Collections::Generic;
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #using &lt;mscorlib.dll&gt;
  
  
  public ref class Extended_ListBox: public ListBox{  
  
      public Extended_ListBox(array&lt;String ^&gt; ^ textLineArray, int counter){
          textLineArray_store = gcnew array&lt;String ^&gt;(counter);
          for (int i=0; i&lt;counter; i++){
              this-&gt;Items-&gt;Add(textLineArray[i]);
              textLineArray_store[i] = textLineArray[i];
          }
          this-&gt;FormattingEnabled = true;
          this-&gt;Size = System::Drawing::Size(380, 225);
          this-&gt;TabIndex = 0;
          this-&gt;SelectedIndexChanged += gcnew System::EventHandler(this, &amp;Extended_ListBox::listBox1_SelectedIndexChanged);
      }
      public Extended_ListBox(){
          this-&gt;FormattingEnabled = true;
          this-&gt;Size = System::Drawing::Size(380, 225);
          this-&gt;TabIndex = 0;
          this-&gt;SelectedIndexChanged += gcnew System::EventHandler(this, &amp;Extended_ListBox::listBox1_SelectedIndexChanged);
      }
      private: System::Void listBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
                   int index=this-&gt;SelectedIndex;
                   tempstring = textLineArray_store[index];
           }  
  
  private: array&lt;String ^&gt; ^ textLineArray_store;
  private: String ^tempstring;
  public: String ^GetSelectedString(){
              return tempstring;
          }
  public: void ListBox_Update(array &lt;String ^&gt; ^ textLineArray, int counter){
          textLineArray_store = gcnew array&lt;String ^&gt;(counter);
          for (int i=0; i&lt;counter; i++){
              this-&gt;Items-&gt;Add(textLineArray[i]);
              textLineArray_store[i] = textLineArray[i];
          }
          }
  };
  </code></pre>