public virtual bool UpdateGridColumns(BindingListView bindingListView, DataGridViewColumn[] columnArray) { bool changed = false; var properties = bindingListView.GetItemProperties(new PropertyDescriptor[0]) .Cast <PropertyDescriptor>() .ToDictionary(pd => pd.Name, pd => pd); for (int iCol = 0; iCol < columnArray.Count(); iCol++) { var dataGridViewColumn = columnArray[iCol]; PropertyDescriptor pd; if (!properties.TryGetValue(dataGridViewColumn.DataPropertyName, out pd)) { continue; } if (dataGridViewColumn.SortMode == DataGridViewColumnSortMode.NotSortable) { dataGridViewColumn.SortMode = DataGridViewColumnSortMode.Automatic; changed = true; } if (!typeof(ILinkValue).IsAssignableFrom(pd.PropertyType)) { continue; } var textBoxColumn = dataGridViewColumn as DataGridViewTextBoxColumn; if (textBoxColumn == null) { continue; } var linkColumn = new DataGridViewLinkColumn { Name = textBoxColumn.Name, DataPropertyName = textBoxColumn.DataPropertyName, DisplayIndex = textBoxColumn.DisplayIndex, HeaderText = textBoxColumn.HeaderText, SortMode = textBoxColumn.SortMode, }; columnArray[iCol] = linkColumn; changed = true; } return(changed); }
public BindingListEventHandler(BindingListView bindingListView) { BindingListView = bindingListView; BindingListViewReset(); }
public void Dispose() { BindingListView = null; }
protected virtual void WriteData(IProgressMonitor progressMonitor, TextWriter writer, BindingListView bindingListView, IDataFormat dataFormat) { var tempBindingListView = new BindingListView(new ViewInfo(ParentColumn, bindingListView.GetViewSpec()), bindingListView.ToArray()); var tempDataGridView = new BoundDataGridView { DataSource = new BindingSource(tempBindingListView, ""), SelectionMode = DataGridViewSelectionMode.FullRowSelect, ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithAutoHeaderText, RowHeadersVisible = false, Visible = false, BindingContext = new BindingContext(), AllowUserToAddRows = false, }; using (tempDataGridView) { var status = new ProgressStatus("Writing " + tempDataGridView.Rows.Count + " rows"); dataFormat.WriteRow(writer, tempDataGridView.Columns.Cast <DataGridViewColumn>().Select(column => column.HeaderCell.EditedFormattedValue)); var rowCount = tempDataGridView.Rows.Count; for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { if (progressMonitor.IsCanceled) { return; } status = status.ChangeMessage("Writing row " + (rowIndex + 1) + "/" + rowCount) .ChangePercentComplete(rowIndex * 100 / rowCount); progressMonitor.UpdateProgress(status); var row = tempDataGridView.Rows.SharedRow(rowIndex); dataFormat.WriteRow(writer, row.Cells.Cast <DataGridViewCell>() .Select(cell => cell.GetEditedFormattedValue(rowIndex, DataGridViewDataErrorContexts.Formatting | DataGridViewDataErrorContexts.ClipboardContent))); } } }
public virtual string GetDefaultExportFilename(BindingListView bindingListView) { string currentViewName = bindingListView.ViewInfo.Name; return(ParentColumn.PropertyType.Name + currentViewName == GetDefaultViewName() ? "" : currentViewName); }