How to add rows and columns to a DataGrid in Compact Framework 3.5

2

I'm new programming in C # and I'm making an application for a Windows 7 embedded device in which a DataGrid will be used but I can not find the way to add data and columns, in the 3.5 framework if the following code works for me:

mydatagrid.Columns.Add("apellido", "Apellido");

But in the Compact No, how can I add rows and columns? Thanks for your help

    
asked by roboto10 12.10.2018 в 21:43
source

1 answer

1

DataGrid is not for manipulating data, so you can not edit, delete, add directly to the control, therefore you have to use a data source as a DataTable.

For your case you must add the column and the data to your data source.

Example:

DataTable dataTable = new DataTable();
dataTable.Columns.Add("Nombre");
dataTable.Rows.Add("Feder");
dataGrid1.DataSource = dataTable;

All data manipulation must be done in the DataTable, it will automatically be synchronized with the DataGrid control.

    
answered by 12.10.2018 / 23:46
source