DataGridView - Overview - Dataset

O

Oliver Stippe

Hello,

I'm searching a good overview for that.

DataGridView dataGridView1 = new DataGridView();
DataTable dt = new DataTable ("Daten");

dt.Columns.Add(new DataColumn("Name"));
dt.Columns.Add(new DataColumn("Reich", typeof(bool)));
dt.Columns.Add(new DataColumn("Neffen", typeof(int)));
dt.Columns.Add(new DataColumn("Geburtsdatum", typeof(DateTime)));

dataGridView1.DataSource = dt;

DataRow dr = dt.NewRow();
dr[0] = "Test"
dr[1] = "ja";
dr[2] = 3;
dr[3] = "24.02.2009";
dt.Rows.Add(dr);

A) User selct a row
DataGridViewRow cRow = masterDataGridView.CurrentRow;

How can I read the cells?
A1) I know the name of column
not work string s2 = cRow.Cells["IDMT"].ToString();
A2) I know the index


B) Is it possible to a select row to a dataset strcuture?
DataGridViewRow cRow = masterDataGridView.CurrentRow;
B1) not work //Lebensmittel.MasterRow mRow =
(Lebensmittel.MasterRow)masterDataGridView.CurrentRow;

Background
I need the reference for my detail table (foreign key) to fill
automatically the list.

C) User select with the mouse a cell
row 3, column 4
Afterthen, I want to know the value.
The actual row.
The name of column.
Nice to have the typ, string, int, double, how?

D) User select with the mouse a column
Column 4
Values
D1) Name of column
D2) foreach , loop, all values.
How?

Thanks.

Greats
Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top