// Create column styles for this TableStyle internal void CreateColumnsForTable(bool onlyBind) { CurrencyManager mgr = manager; DataGridColumnStyle st; if (mgr == null) { mgr = datagrid.ListManager; if (mgr == null) { return; } } for (int i = 0; i < column_styles.Count; i++) { column_styles[i].bound = false; } table_relations.Clear(); PropertyDescriptorCollection propcol = mgr.GetItemProperties(); for (int i = 0; i < propcol.Count; i++) { // The column style is already provided by the user st = column_styles[propcol[i].Name]; if (st != null) { if (st.Width == -1) { st.Width = CurrentPreferredColumnWidth; } st.PropertyDescriptor = propcol[i]; st.bound = true; continue; } if (onlyBind == true) { continue; } if (typeof(IBindingList).IsAssignableFrom(propcol[i].PropertyType)) { table_relations.Add(propcol[i].Name); } else { st = CreateGridColumn(propcol[i], true); st.bound = true; st.grid = datagrid; st.MappingName = propcol[i].Name; st.HeaderText = propcol[i].Name; st.Width = CurrentPreferredColumnWidth; column_styles.Add(st); } } }
/// <summary> /// Called by a DataGrid when it wishes to preserve its /// transient state in the current DataGridState object. /// </summary> public void PushState(DataGrid dataGrid) { DataSource = dataGrid.DataSource; DataMember = dataGrid.DataMember; DataGrid = dataGrid; DataGridRows = dataGrid.DataGridRows; DataGridRowsLength = dataGrid.DataGridRowsLength; FirstVisibleRow = dataGrid.firstVisibleRow; FirstVisibleCol = dataGrid.firstVisibleCol; CurrentRow = dataGrid.currentRow; GridColumnStyles = new GridColumnStylesCollection(dataGrid.myGridTable); GridColumnStyles.Clear(); foreach (DataGridColumnStyle style in dataGrid.myGridTable.GridColumnStyles) { GridColumnStyles.Add(style); } ListManager = dataGrid.ListManager; ListManager.ItemChanged += new ItemChangedEventHandler(DataSource_Changed); ListManager.MetaDataChanged += new EventHandler(DataSource_MetaDataChanged); CurrentCol = dataGrid.currentCol; }