title: Searching for a tabpage in the tabcontrol C#
body: <p>I have a tabcontrol in my application. I have a listbox which contains the line no of error and file name and path of the file.On double click i want to add the new tab page.The title of the tabpage should be the name of file from the listbox. If the tabpage with the particular filename already exists then it should not open new tabpage the cursor should point to that page. How to retreive the name of the tabpages .</p>
  
  <pre><code>private void lstErrorList_MouseDoubleClick(object sender, MouseEventArgs e)
          {
              ArrayList errorType = new ArrayList();
              if (lstErrorList.Items.Count &gt; 0)
              {
                  string error = lstErrorList.SelectedItem.ToString();
  
  
  
                  {
  
                      int result = error.LastIndexOf('\\');
                      string filename = error.Substring(result + 1, error.Length - (result + 1));
                      int pagecount;
                      TabPage tp = new TabPage();
                      pagecount = this.tabControl1.TabPages.Count;
                      for(int tbpagecount=0;tbpagecount&lt;pagecount;tbpagecount++)
                      {
                          pagelist.Add(this.tabControl1.TabPages.ToString());
                      }
                      if (pagelist.Contains(filename))
                      {
  
  
                      }
                      else
                      {
                          this.tabControl1.TabPages.Insert(pagecount, filename);
                          pagecount++;
                      }
  
                      if (fileNamesList.Count == 0)
                          fileNamesList.Add(filename);
                      else
                      {
                          if (fileNamesList.Contains(filename))
                          {
                              //fileNamesList.Add("");
                          }
                          else
                          {
                              fileNamesList.Add(filename);
  
                          }
  
                      }
                  }  
  </code></pre>