Read number from text file and display it in a textbox in C# -
i have text file (abcd.txt) contains number (456700010234) in it. abcd.txt file contains number (456700010234). nothing else.
i want display number in 1 of text boxes in c# form. prefer not use button. textbox in form/usercontrol.
if anytime want change number, update text file (abcd.txt) new number , thus, new number appear in textbox automatically each time open form. way, won't have re-program software whenever number changes. want update .txt file new number if number changes.
you first have create handler form_load
event, this:
private void form1_load(object sender, system.eventargs e) { }
then need set text
property of text box result of reading of data (one line) text file, this:
private void form1_load(object sender, system.eventargs e) { yourtextbox.text = file.readalltext("abcd.txt"); }
now whenever form loads go out , read contents of file , display number in text file user.
Comments
Post a Comment