End Google Ads 201810 - BS.net 01 --> Guys,

I`m working on a Windows application and running into a problem, can`t seem to figure it out. Let me first explain the app. Its a windows forms application with a Tab Controls. Each Tab Control is a single file and has other controls within it [tabcontrols, buttons, etc etc]. Based on the file extension only the First tab within the Tab Control changes everything else remains the same. Lets say like a Web browser with Tabs.

The problem I`m running into is - How do I stop duplicate tabcontrols [each tab control is a file] from opening. Lets say I load a file ABC.opt how do make sure ABC.opt is not loaded again..i.e, open by the software. I can load files now, but can`t seem to control the duplicates.
Also, when i Save a file..I want only the contents of the Tab Control open to be saved. Is there a Tab Control active property? What is the best way to do it. Something like a Web Browser..Lets say you open a website in a tab and click on Save on the Menu Strip, only the active Tab is saved.

Here is the code I`m working on.

//File Item Clicked from the MainMenuItem - This has File New, File Open, Save, Save As, etc
private void FileToolStripMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
FileToolStripMenuClicked(e.ClickedItem);
}

//FTSI - File Tool Strip Item Clicked
private void FileToolStripMenuClicked(ToolStripItem FTSI)
{


switch (FTSI.Name)
{

case "FileOpenTSMI":
// FileOpen.cs
FileOpen FO = new FileOpen();
FO.OpenFile();

break;

case "FileSave"
//See comments in ABCOpen

//Code here
break;


default:
break;
}
}




//Based on the Extention of the file the ABCOpen() or XYZOpen() functions are called
internal void OpenFile()
{
OpenFileDialog OFD = new OpenFileDialog();
OFD.InitialDirectory = @"C:\Cust";
OFD.Filter = "ABC Files|*.abc|XYZ Files|*.xyz";
OFD.CheckFileExists = true;
OFD.CheckPathExists = true;
OFD.RestoreDirectory = true;


if (OFD.ShowDialog() == DialogResult.OK)
{
switch (Path.GetExtension(OFD.FileName).Substring(1))
{
case "abc":
ABCOpen(OFD.FileName);
break;

case "xyz":
XYZOpen("OFD.FileName");
break;

default:
break;

}

}
}


private void ABCOpen(string FileName)
{
// Code here loads some User Controls




// Code here reads a File and then loads the data into Windows forms
// How do I save it in such a way that only the active tab control data is saved
// Lets say I loaded Sample.abc and Test.xyz. I edit Sample.abc and it is the active Tab, and when I hit save how can I make sure only Sample.abc data is written into the file?

}


Any ideas, help are greatly appreciated.

Thanks!