Jump to content

save button

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
elizabethmwashuma

elizabethmwashuma

    Newbie

  • Members
  • PipPip
  • 29 posts
hi everyone,
i am creating a window application and its supposed to enter details then the details entered need to be saved.
i want to know how to save the information entered by a data clerk in the form

regards,

#2
BuckAMayzing

BuckAMayzing

    Learning Programmer

  • Members
  • PipPipPip
  • 39 posts
There are so many options. You can connect to a database to save the data, create a plain text file, a custom binary file, you could choose whether to encrypt or not. There really are a lot of options. The easiest way is plain text.

 // create a writer and open the file
            TextWriter tw = new StreamWriter("filename.txt");

            // write a line of text to the file
            tw.WriteLine(TextBox1.Text);

            // close the stream
            tw.Close();

However, loading the data may be more difficult that way if the file size becomes large. You should decide how you want to store your data before you worry about saving it.

#3
elizabethmwashuma

elizabethmwashuma

    Newbie

  • Members
  • PipPip
  • 29 posts
thank you BuckAMayzing for your response.....so where exactly would i put the code.....on button click or on form_load?

#4
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
the code in form_load is executed when the form is loaded. If you want to save the data when you click the button, put it in the button_click event.
For more, check out the link to the tutorial in my signature
|
|
\ /
v
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics

#5
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
I am sure you need more security for your data than just plane text ,check out how to serialize characters & protect from being read by common man
http://forum.codecal...-basic-net.html