Click here to Skip to main content
15,908,115 members
Home / Discussions / C#
   

C#

 
GeneralRe: ListView in C#.net Pin
phil.o3-Dec-10 2:33
professionalphil.o3-Dec-10 2:33 
GeneralRe: ListView in C#.net Pin
Hiren solanki3-Dec-10 2:37
Hiren solanki3-Dec-10 2:37 
QuestionLinq in 3.0 Framework Pin
Tiger4562-Dec-10 18:57
Tiger4562-Dec-10 18:57 
AnswerRe: Linq in 3.0 Framework Pin
Hiren solanki2-Dec-10 19:21
Hiren solanki2-Dec-10 19:21 
GeneralRe: Linq in 3.0 Framework Pin
Tiger4562-Dec-10 20:50
Tiger4562-Dec-10 20:50 
AnswerRe: Linq in 3.0 Framework Pin
Hiren solanki2-Dec-10 21:44
Hiren solanki2-Dec-10 21:44 
GeneralRe: Linq in 3.0 Framework Pin
Tiger4562-Dec-10 21:57
Tiger4562-Dec-10 21:57 
QuestionSave and Save as [modified] Pin
squerley2-Dec-10 10:20
squerley2-Dec-10 10:20 
Hi Im new to programming, im taking an online class and sometimes it takes a while for someone to get back to me.

We created a notepad program and i want the user of the program to be able to save the file and once the first initial save is saved it wont prompt the user with another pop up asking where to save the file it will automatically save it to the last place it was saved. While writing this i think i answered my other question for the save as haha =^) the Save As would just use the same save click event method.haha

The other is how would i check to see if the user has saved there file prior to closing the program.
//This is my save:

private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {            
            SaveFileDialog saveFile = new SaveFileDialog();

            saveFile.Title = "Save File";
            saveFile.Filter = "Text File|*.txt|All Files (*.*)|*.*";

            DialogResult dr = saveFile.ShowDialog();
            if (dr == DialogResult.OK)
            {
                StreamWriter sw = new System.IO.StreamWriter(saveFile.FileName);
                
                Form activeForm = this.ActiveMdiChild;

                if (activeForm != null)
                {
                    TextBox activeText = (TextBox)activeForm.ActiveControl;

                    if (activeText != null)
                    {
                        sw.Write(activeText.Text);
                        sw.Close();
                    }
                }
            }
        }

//this is my close, it works but not right if the person has saved their data it will still show the message box because it has text in the text box.
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (edittextBox.Text != null)
            {
                MessageBox.Show("Please make sure you save your data!");
            }
            else
            {
                Close();
            }
        }


Thanks for your Help ?=^)
modified on Friday, December 3, 2010 9:01 PM

AnswerRe: Save and Save as Pin
Pete O'Hanlon2-Dec-10 10:36
mvePete O'Hanlon2-Dec-10 10:36 
GeneralRe: Save and Save as Pin
GenJerDan2-Dec-10 11:25
GenJerDan2-Dec-10 11:25 
GeneralRe: Save and Save as Pin
squerley2-Dec-10 11:39
squerley2-Dec-10 11:39 
GeneralRe: Save and Save as Pin
Pete O'Hanlon2-Dec-10 11:55
mvePete O'Hanlon2-Dec-10 11:55 
GeneralRe: Save and Save as Pin
Dalek Dave2-Dec-10 12:26
professionalDalek Dave2-Dec-10 12:26 
AnswerRe: Save and Save as Pin
GenJerDan2-Dec-10 11:29
GenJerDan2-Dec-10 11:29 
GeneralRe: Save and Save as Pin
squerley2-Dec-10 12:15
squerley2-Dec-10 12:15 
GeneralRe: Save and Save as Pin
GenJerDan2-Dec-10 17:22
GenJerDan2-Dec-10 17:22 
GeneralRe: Save and Save as Pin
Dalek Dave2-Dec-10 12:27
professionalDalek Dave2-Dec-10 12:27 
AnswerRe: Save and Save as Pin
Luc Pattyn2-Dec-10 12:10
sitebuilderLuc Pattyn2-Dec-10 12:10 
AnswerRe: Save and Save as Pin
_Erik_3-Dec-10 3:22
_Erik_3-Dec-10 3:22 
GeneralRe: Save and Save as Pin
squerley3-Dec-10 8:59
squerley3-Dec-10 8:59 
GeneralRe: Save and Save as Pin
squerley4-Dec-10 16:08
squerley4-Dec-10 16:08 
GeneralRe: Save and Save as Pin
_Erik_6-Dec-10 23:35
_Erik_6-Dec-10 23:35 
GeneralRe: Save and Save as Pin
squerley10-Dec-10 15:46
squerley10-Dec-10 15:46 
QuestionHow to delete word field code from C# Pin
Andraw Tang2-Dec-10 8:45
Andraw Tang2-Dec-10 8:45 
QuestionXPathNavigator iterate and write Pin
Mark F.2-Dec-10 5:38
Mark F.2-Dec-10 5:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.