c# - Open file with tabs -


here's code opening new file:

private void opentoolstripmenuitem_click(object sender, eventargs e) {     openfiledialog openfd = new openfiledialog();     string chosen_file = "";      openfd.initialdirectory = "c:";     openfd.title = "open text file";     openfd.filename = "";      openfd.filter = "text files|*.txt|word documents|*.doc";      if (openfd.showdialog() != dialogresult.cancel)     {          chosen_file = openfd.filename;         getrichtextbox().loadfile(chosen_file, richtextboxstreamtype.plaintext);      } 

i'm using tabs also. can open files when have tab opened. how can set open new tab file? works when open tab , open file.

you have add new tabpage tabcontrol before loading file (the way in code):

tabpage tab = new tabpage(){text = system.io.path.getfilename(chosen_file)}; tabcontrol1.tabpages.add(tab); tabcontrol1.selectedtab = tab; richtextbox rich = new richtextbox{parent = tab, dock = dockstyle.fill}; rich.loadfile(chosen_file, richtextboxstreamtype.plaintext); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -