473,396 Members | 2,082 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,396 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 3116
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.