through file handling i am stroing diffrent values of fiffrent controls like name and age etc
if i enter a name of length 10 and next is of 5 in output file it destroys the strucher like
name age date of admission
Muhammad kashif 20 12/aug/2012
ali 20 12/aug/2012
but i want
name age date of admission
Muhammad kashif 20 12/aug/2012
ali 20 12/aug/2012
so help me. in my real file i have about ten values so reading then in this strucher is very
difficult. but if these are managed then it is easy.
Loading
VulpesPosted Aug 16, 2012, 11:51 AM
http://www.c-sharpcorner.com/Forums/Thread/182470/data-writing-from-multiple-controls-in-same-file.aspx
ta muPosted Aug 16, 2012, 11:44 AM
plz provide solution printing form. just cosider there is a print button on form when i press
button all controls with there present values get printed through printer.
VulpesPosted Aug 16, 2012, 11:36 AM
If it's not being written to the file, then there must be something else in your code which is causing those lines to be by-passed.
ta muPosted Aug 16, 2012, 11:25 AM
data successfully saved in file. i just want to formate like data remain in a fix
area
VulpesPosted Aug 16, 2012, 10:53 AM
If, for some reason, you're having to write it field by field using separate StreamWriters, then I'd use String.PadRight instead:
ta muPosted Aug 16, 2012, 2:03 AM
dear if this is code then where i adjust that code.or either i need to embed this code in
visiual app mean in propertiesthis this is my first practical aplication before it
i never developed . pname max length is 25 and age is 3.
StreamWriter pname = new StreamWriter("d:\\hospital records.text", true);
string paaname = ptname.Text + " " + " " + " " + " ";
pname.Write(paaname);
pname.Close();
StreamWriter age = new StreamWriter("d:\\hospital records.text", true);
string aage = agee.Text + " " + " " + " " + " ";
age.Write(aage);
age.Close();
VulpesPosted Aug 15, 2012, 10:37 AM
As Sukesh said, you have to decide on a maximum length for the name. I've just used 20 characters here so it's easy to read the resulting lines:
Sukesh MarlaPosted Aug 15, 2012, 8:06 AM
Then Append n spaces after actual value before storing into file
where n=100-Length(ActualValue)
Dont forget to check this is correct answer