FAQ: DataGrid Compact Framework 2.0
Algunas de las tareas más comunes al trabajar con un Grid con el Compact Framework.
Cambiar el texto del titulo a una columna
Para esto necesitamos trabajar minimo con u nTableStyle.
myDataGrid.TableStyles[0].GridColumnStyles[0].HeaderText = “My Header”
The key is knowing which TableStyle to get. If there is only one TableStyle on your grid, or if you are generating columns in the datagrid automatically, you can just get the first TableStyle in the collection, since there is only one. Otherwise you have to know the position and/or mapping name of the table style.
NOTE: The generally accepted recommendation is to not auto-generate the columns if you know what they will be at design-time; go ahead and set them up at design time. This allows you to store them in their own member variables and manipulate them more easily, including setting their HeaderText, e.g. MySecondColumnStyle.HeaderText = “Second Column”
Esconder una columna
Para mi no es posible, una alternativa es poner el Width a -1.
Acceder al contenido de una celda
dataGrid1[0,1]
Usar TableStyles para con un DataTable
Definir el TableStyle en tiempo de diseño.
DataTable dt = oSession.LoadSessionTable();
dgTrack.DataSource = dt;
dgTrack.TableStyles[0].MappingName = dt.TableName;
dgTrack.TableStyles[0].GridColumnStyles[0].MappingName = dt.Columns[0].ColumnName; // Sess ID
dgTrack.TableStyles[0].GridColumnStyles[1].MappingName = dt.Columns[1].ColumnName; // Act ID
dgTrack.TableStyles[0].GridColumnStyles[2].MappingName = dt.Columns[2].ColumnName; // Date
en 14 Junio, 2008 en 2:06 pm
Sos un capo