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 .
private void lstErrorList_MouseDoubleClick(object sender, MouseEventArgs e)
{
ArrayList errorType = new ArrayList();
if (lstErrorList.Items.Count > 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<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);
}
}
}
bool found = false;
foreach (TabPage tab in tabControl1.TabPages) {
if (filename.Equals(tab.Name)) {
tabControl1.SelectedTab = tab;
found = true;
}
}
if( ! found)
tabControl1.TabPages.Add(filename,filename);
var tabPage = tabControl1.TabPages[filename];
if (tabPage != null)
{
tabControl1.SelectedTab = tabPage;
}
else
{
tabControl1.TabPages.Add(filename, filename);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With