I'm not using a database but a txt file to store stuff and i want to continue doing so. Is there any way i can load stuff into the datagrid without loading it from a database? Else, what object should i use?
Printable View
I'm not using a database but a txt file to store stuff and i want to continue doing so. Is there any way i can load stuff into the datagrid without loading it from a database? Else, what object should i use?
Elaberate on Stuff because you could write it out to a file (*.txt) and then load and bind at run time with ADO.Net but that is still in a sense a database.....
elaberate some
It also depends on how those "stuff" :D is organized in the file, but it is possible. However if you wanted to make things really easier, you could use an XML file, as it makes things really simple when you are reading and writing from the file.
There is an example in the C# forum about how to do this in XML.
Hope that helped.
So you can bind a control to an xml object? I don't know don't use XML much
can you post a link to the thread?
Here is the link
Have fun
http://vbforums.com/showthread.php?s=&threadid=150451
i will check it out
i checked it out but it still want to use the plain old textfile. I don't know much about xml and just loading text into the dataobject sounds much better to me ;-)
And BTW i already made loading and saving procedures and they work very well. It's just that i can't get any data into the DataGrid....all the examples use XML.
Ok, here is a scenario.
Make a struct or a class for the type of data in the text that you want to load. You can read a block of lines into the struct or the class then add that struct or class to a dynamic array (arraylist). Each block of lines should be one record separated by a blank line or whatever you choose.
after you have read all the records, just write a foreach loop and load everything in the datagrid.
Post an example of the text file with the stuff you are trying to load and I will tell you best way to do it.
after you have read all the records, just write a foreach loop and load everything in the datagrid.
that's what i'm asking! i know how to do the loop that's no problem but how can i add text to the datagrid?
About the textfile, it's for a program that help you to learn words.
a file looks like this:
TOMMY2K
hallo=hello
stoel=chair
eten=to eat
tafel=table
hond=dog
kat=cat
frans=french
lopen=to walk
geluid=sound
SLUITEN
the first word is a dutch word and the second one is (duhh) english
Now i made some nice loops to loop this into 2 arrays. the first one called Knownwords contains the dutch words and the second one called Unknownwords contains the english words. I need 2 colomns for the datagrid, 1 for the know- and one for the unknown words. I already did this using a listbox but that really doesn;t do. Thnx for all the help you can give me!
PS: the TOMMY2k and SLUITEN are open and close tags...
Ok cool, there should be a way to load the data into the data grid. I wont be able to try this until I go home later, so please be patient.
Anyway, just keep trying until you come up with something