internal void Sort (DataGridColumn column) { sortColumn = column.ColumnIndex; sortComparer = column.ContentComparer; if (column.SortIndicator) column.SortOrder = ReverseSortOrder (column); //show indicator on current column, remove on all others foreach (TreeViewColumn col in grid.Columns) col.SortIndicator = col == column; store.SetSortFunc (column.ColumnIndex, new TreeIterCompareFunc (SortFunc)); store.SetSortColumnId (column.ColumnIndex, column.SortOrder); }
public void DataBind () { if (dataSource == null) { Clear (); return; } int index = 0; Type[] storeTypes = new Type[dataSource.Columns.Count]; columnCount = dataSource.Columns.Count; foreach (DataColumn col in dataSource.Columns) { DataGridColumn dgCol = new DataGridColumn (this, col, index); grid.AppendColumn (dgCol); if (col.DataType == typeof (byte)) { //special case for gchar (TODO: look up the bugzilla bug id) storeTypes[index] = typeof (string); conversionLookup.Add (index, byteConvertFunc); } else if (col.DataType == typeof (sbyte)) { storeTypes[index] = typeof (string); conversionLookup.Add (index, sbyteConvertFunc); } else if (col.DataType.IsPrimitive || col.DataType == typeof (string) || col.DataType.IsEnum) { storeTypes[index] = col.DataType; } else { //the ListStore doesn't allow types that can't be converted to a GType storeTypes[index] = typeof (object); } index++; } store = new ListStore (storeTypes); grid.Model = store; TreeIterCompareFunc sortFunc = new TreeIterCompareFunc (SortFunc); store.SetSortFunc (0, sortFunc); store.SetSortColumnId (0, SortType.Ascending); //TODO: is this needed ? NavigateToRecord (0); }