|
Free
C# Tutorials
|
![]() |
home |
Stay
at Home and Learn
|
|||||
Add a Save As Dialogue Box to your C# Programmes |
||||||
|
<< Continues from the previous lesson Another useful Method you can use with the RichTextBox is SaveFile( ). As its name suggests, this allows you to save the file that's currently in the text box. We'll use this with another Dialog object. This time, we'll use the SaveFileDialog control instead of the OpenFileDialog control. Return to you form, and locate the SaveFileDialog control in the Toolbox:
Double click to add one to your project. It should appear at the bottom of your screen:
Click on saveFileDialog1 to select it. Now have a look at the Properties on the right hand side of the screen. Change the Name property to saveFD:
Now go back to your File menu, on your Menu Strip. Click on File, then double click your Save menu item. This will open up the code for this item:
The code to add a Save option is practically the same as for the Open menu item. Instead of saying openFD, though, it's saveFD. Here it is:
You should be able to work out what's happening, in the code above. The line that does the saving is this one: richTextBox1.SaveFile(Saved_File, RichTextBoxStreamType.PlainText);
<-- Open a Text File | CheckBoxes and RadioButtons --> <--Back to the C# .NET Contents Page View all our Home Study Computer Courses
|