Hi,
selecting one or more Headers in the UlttraGrid and pressing Strg-C, copies the first Header and left upper cell. The cell selection below the selected Headers is correct.
The grid should work similar as Excel. The User shoulod be able to select several culumns, by clicking on the header and copy the values incl. the header text into a excel sheet.
I use the following settings:
grid.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.False;grid.DisplayLayout.ColScrollRegions.Add(colScrollRegion1);grid.DisplayLayout.ColScrollRegions.Add(colScrollRegion2);grid.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;grid.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;grid.DisplayLayout.Override.AllowMultiCellOperations = ((Infragistics.Win.UltraWinGrid.AllowMultiCellOperation)((Infragistics.Win.UltraWinGrid.AllowMultiCellOperation.CopyWithHeaders | Infragistics.Win.UltraWinGrid.AllowMultiCellOperation.Paste)));grid.DisplayLayout.Override.RowSizingArea = Infragistics.Win.UltraWinGrid.RowSizingArea.RowBordersOnly;grid.DisplayLayout.Override.SelectTypeCell = Infragistics.Win.UltraWinGrid.SelectType.Extended;grid.DisplayLayout.Override.SelectTypeCol = Infragistics.Win.UltraWinGrid.SelectType.Extended;grid.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Extended;grid.DisplayLayout.Override.SummaryDisplayArea = Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.None;grid.DisplayLayout.Scrollbars = Infragistics.Win.UltraWinGrid.Scrollbars.Both;grid.DisplayLayout.UseFixedHeaders = true;grid.DisplayLayout.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.SingleBand;grid.Dock = System.Windows.Forms.DockStyle.Fill;grid.Location = new System.Drawing.Point(0, 0);grid.Name = "grid";grid.Size = new System.Drawing.Size(723, 584);grid.TabIndex = 5;grid.Text = "ultraGrid1";grid.UseOsThemes = Infragistics.Win.DefaultableBoolean.True;grid.Error += new Infragistics.Win.UltraWinGrid.ErrorEventHandler(grid_Error);grid.KeyDown += new System.Windows.Forms.KeyEventHandler(grid_KeyDown);grid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(grid_InitializeRow);grid.Validated += new System.EventHandler(grid_Validated);grid.KeyPress += new System.Windows.Forms.KeyPressEventHandler(grid_KeyPress);grid.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(grid_InitializeLayout);grid.AfterRowRegionScroll += new Infragistics.Win.UltraWinGrid.RowScrollRegionEventHandler(grid_AfterRowRegionScroll);grid.AfterSelectChange += new Infragistics.Win.UltraWinGrid.AfterSelectChangeEventHandler(grid_AfterSelectChange);
Any Ideas how to solve this?
Thank you ! I use 2009.1, I guess it doesn't support the Column property. I will need to find the right property for column name.
I can only assume that the version of the UltraGrid doesn't have the same properties as the version I was using. The code is essentially using Linq to get an IEnumerable list of the column names currently selected here:
var columns = ultraGrid1.Selected.Columns.Cast<ColumnHeader>().Select(i => i.Column);
Then, it uses Linq to get a list of all the cells for every row for the selected columns.
var cells = ultraGrid1.Rows.Cast<UltraGridRow>().SelectMany(i => i.Cells.Cast<UltraGridCell>().Where(j => columns.Contains(j.Column)));
This is essentially doing the same thing as a SQL "IN" statement and it's getting all of the cells which have a column named the same as the selected columns. I'm assuming this is the line you're getting the error and I'm guessing it's coming from one of two problems:
1. A null columns list. I don't do a test to ensure that this list isn't null and perhaps you need to.
2. Inside the Where clause. I'm using WinGrid 2009.2 and an UltraGridCell has a Column property with the name of the column in it. Does your UltraGridCell have the Column property in it?
Good luck!
robarch, I used your code but got error message "cannot resolve symbol 'Column' " when getting the value of columns. Do you have any idea why ?
Hi David,
The word is that this is currently working as designed and this is considered a feature request. So it may be added in a future release. :)
robarch - your solution works great for me too!
Mike - any word on a bugfix for this?
Thanks to both of you!
David McClelland