Rename tab as opened file name (C#)

This post I will show you how rename the tab name as file name.

  1. First you have to import some libraries.
  2. Import them as follows
  3.         using System.IO;
            
  4. Go to Open submenu code part.
  5. before the close() the Open file dialog put this code
  6.             tabControl1.SelectedTab.Text = Path.GetFileName(ofd.FileName);
            

Next we will see how change tabb's name after the save it

  1. Goto Save submenu's code part and put the following code parts
  2.         tabControl1.SelectedTab.Text = Path.GetFileName(sfd.FileName);
            

No comments:

Post a Comment