|
Hello All C# coders, i am wanting to know how i can change
my form title from a .txt file called
"Title_form.txt"
Thanks
|
|
|
|
|
Set the Winform's Form Title using the Text property.
Can you elaborate more on the requirement, especially what you wish to achieve by changing the tile from a Text file?
|
|
|
|
|
Oh i just want to learn how to do it, iv seen programs where you can edit things just by using .txt files
|
|
|
|
|
If this is just a proof of concept ignore my comment below
If this is to start creating configuration for your application a txt file will work, but is probably not the best option around there. You can use
- ini files (Please don't)
- xml files (better)
- App.config or similar (recommended, certainly if you want machine based settings)
- Database (I usually use this one as much as possible and use an app.config to point to the database)
Note that there is a difference between user settings (eg, language, application options, ...) and system settings (time outs, root paths, database connection strings, ...) You might want to split those.
Just for info.
|
|
|
|
|
V. wrote: - Database (I usually use this one as much as possible and use an app.config to
point to the database)
|
|
|
|
|
you can change as this.text = "Title_form"
|
|
|
|
|
Yes, but i would like to know how to make it read from a .txt file called Title_form and change the forms title with that .txt
|
|
|
|
|
if you mean that you want to make your form title as your text file name???
|
|
|
|
|
No i want the program to read from a .txt called Title_form.txt and then inside that .txt i have the form name.
|
|
|
|
|
TextReader tr = new StreamReader(C\\test.txt);
//How many lines should be loaded?
int NumberOfLines = 15;
//Make our array for each line
string[] ListLines = new string[NumberOfLines];
//Read the number of lines and put them in the array
for (int i = 1; i < NumberOfLines; i++)
{
ListLines[i] = tr.ReadLine();
}
if the title is in number 5 line
this.text = ListLines[5];
one all the lines are added in the array then you can pick your desired one.
hope this will help you..
|
|
|
|
|
it says im missing a Assembly reference are there any imports for this method?
|
|
|
|
|
using System.IO;
Try that one.
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image.
Stephen Hawking
|
|
|
|
|
include using system.io.stream
|
|
|
|
|
Thank you so much all it works!
|
|
|
|
|
Sure you can just use the refactoring in the IDE
|
|
|
|