示例#1
0
        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);
        }
示例#2
0
 public BindingListEventHandler(BindingListView bindingListView)
 {
     BindingListView = bindingListView;
     BindingListViewReset();
 }
示例#3
0
 public void Dispose()
 {
     BindingListView = null;
 }
示例#4
0
        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)));
                }
            }
        }
示例#5
0
        public virtual string GetDefaultExportFilename(BindingListView bindingListView)
        {
            string currentViewName = bindingListView.ViewInfo.Name;

            return(ParentColumn.PropertyType.Name + currentViewName == GetDefaultViewName() ? "" : currentViewName);
        }