Click to See Complete Forum and Search --> : Table - How to?


gborges
July 9th, 2008, 08:30 AM
Hi all!

How can I create a table, which has 3 columns? The first column contains a number, the second one contains a datetime field, and the third one contains a text.

In my app there will be a form that I will fill in order to add some new lines at this table.

This table will appears when I press a button at my app. I will not use any kind of database system. I would like to store all data in memory.

Someone could help me to create and store some data in it?

Thank you in advance!

eclipsed4utoo
July 9th, 2008, 09:00 AM
we will not do your homework for you.

gborges
July 9th, 2008, 09:14 AM
I think you should be a little bit more polite.

If you know a good tutorial send me the link, that I can do it by myself. If I sent a question to this forum, it is because I am a beginner in C#, and I searched at the internet and I didn't find anything useful.

I didn't ask to anyone do my job. I only give to the forums members all details that I think it can be relevant.

I will not waste my time replying you.

So, If someone knows something related to how to work with tables in c# send me the link.

Thank you.

eclipsed4utoo
July 9th, 2008, 10:00 AM
look into using a DataGridView. It's default functionality is to allow user editing, adding, and deleting.

nabeelisnabeel
July 9th, 2008, 11:37 AM
'DataTable' class is used for making a table in memory.

'DataTable' class has a collection of 'DataRow' class.

'DataTable' class has a collection of 'DataColumn' class.

You add desired number of columns in DataTable by using Add() method.

DataColumn's constructor takes column name and its data type as parameters.

You add your desired number of rows in table by something like this
DataRow newRow = myDataTable.NewRow();

You add your columns data by something like this
newRow["columnAge"] = 50;
newRow["columnName"] = "Coder";