473,382 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Textfile beim Einlesen Zerstückeln?

Ich habe es nun erreicht, ein textfile einzulesen das nun zeile für zeile im
datagrid angezeigt wird.

Nun wäre es toll wenn ich das textfile zum beispiel nach jedem blank in eine
spalte zerstückeln könnte und meine frage hier wie geht sowas?

Ich habe nun das ganze mit folgendem code im datagrid, nur zu welchem
zeitpunkt zerstückle ich das und meine eigentliche frage wie kann ich das
dann in die jeweiligen spalten stellen?

Beispiel meines textfile:
-----------------------
123 Auto BMW 45000
777 Auto Audi 88000

Schön wäre es wenn ich nun 4 spalten und 2 zeilen hätte. Momentan bringe ich
es auf eine spalte und 2 zeilen.
myDataView.Sort = "Spalte1";

ds.Tables.Add(MyTable);
dataGrid1.DataSource = MyTable;

Wäre toll um eine kleine hilfe von Euch

Danke Gruess

Michael

Nov 15 '05 #1
1 3114
Hi Michael,

Your chances of getting help increase exponentially if you use english -
just because so many more people will understand what you are asking for.
Don't worry if your english isn't perfect, or even broken... many people
reading the news group are not native speakers.

I think this is what you are looking for:

private void Form1_Load(object sender, System.EventArgs e)
{
string delimiters = " ";
string textLine = "This is my text";
DataTable dt = new DataTable("myTable");
dt.Columns.Add("First");
dt.Columns.Add("Second");
dt.Columns.Add("Third");
dt.Columns.Add("Fourth");
dt.Rows.Add(textLine.Split(delimiters.ToCharArray( )));
dataGrid1.DataSource = dt;
}

The code assumes you have created a data grid called dataGrid1 on a form
called Form1.

Eric

"Michael Schindler" <NO**********************@naviti.ch> wrote in message
news:#L**************@TK2MSFTNGP11.phx.gbl...
Ich habe es nun erreicht, ein textfile einzulesen das nun zeile für zeile im datagrid angezeigt wird.

Nun wäre es toll wenn ich das textfile zum beispiel nach jedem blank in eine spalte zerstückeln könnte und meine frage hier wie geht sowas?

Ich habe nun das ganze mit folgendem code im datagrid, nur zu welchem
zeitpunkt zerstückle ich das und meine eigentliche frage wie kann ich das
dann in die jeweiligen spalten stellen?

Beispiel meines textfile:
-----------------------
123 Auto BMW 45000
777 Auto Audi 88000

Schön wäre es wenn ich nun 4 spalten und 2 zeilen hätte. Momentan bringe ich es auf eine spalte und 2 zeilen.
myDataView.Sort = "Spalte1";

ds.Tables.Add(MyTable);
dataGrid1.DataSource = MyTable;

Wäre toll um eine kleine hilfe von Euch

Danke Gruess

Michael



Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Hans A | last post by:
I have a textfile "textfile.txt" containing a list of words. There is one word on each line. I want to pick two random lines from this textfile, and I have tried to do something like: //Loading...
1
by: Larry Rekow | last post by:
I have a report that's created each day as a flat textfile. Because I came from the Access world, I created a macro that imports it with a schema that gives meaningful names to the various...
2
by: juergen.tippmann | last post by:
Hallo, kann mir jemand sagen ob ich beim Öffnen eines Formulars in Access2003, abfragen kann ob z.B. die Strg-Taste gedrückt ist oder nicht?
4
by: Kevin Johnson | last post by:
Hi Using C# and a textfile I need to do two things: 1. Read the contents of the textfile and return the number of words contained in it. 2. Output a list of unqiue words (i.e. not...
8
by: Maximilian Hofer | last post by:
Hallo NG, zum erstellen einer Anfrag an eine Website benutze ich folgenden Code: Dim encoding = New System.Text.UTF8Encoding 'Daten zum Posten zusammenbauen Dim postData As String
8
by: Andi Reisenhofer | last post by:
Hallo, Ich versuche einen Key von einem Programm (www.winhound.com) zu entfernen das sich immer wieder bei mir "einnistet". Der Schlüssel...
1
by: kachokaratz | last post by:
well i have a problem in my project..since the contents of my textfile is too long, i was wondering how to output the textfile in such a way that you can divide the contents to be able to output...
14
by: blumen | last post by:
Hi all, I'm a newbie in VB.Net Programming.. Hope that some of you can help me to solve this.. I'm working out to read,parse and save textfile into SQL Server. The textfile contains thousands...
1
by: asedt | last post by:
With my Excel macro and two text files I want to create a new textfile containing the first textfile then text from the sheet and then the second textfile. My problem is that i don't know how to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.