BUG: GridModel.CopyTextToBuffer

Thread ID:

Created:

Updated:

Platform:

Replies:

Not sure if this is reported yet but I think there is a bug in this function. Do the following (assuming you have a data bound grid with a populated DataTable as its DataSource):
1. Create a RangeInfoList containing one RangeInfo whose type is Cols. Let's say it's called "selections".
2. Call grid.Model.CutPaste.CopyRange(selections);
3. Note that the clipboard is empty.
4. Repeat the first step but use a Cells RangeInfo (for the same range, ie. a bunch of columns) and note that it works as expected.
I think the bug is in the CopyTextToBuffer function where it tries to get the rowRanges and colRanges. The filter should probably include Cols for rangeList.GetRowRanges and vice versa.
FWIW, my version of the grid is 1.6.1.0.
-Peter
PS - An even worse problem occurs when you set the selection RangeInfo to type Table.

Try calling ExpandRange before you pass it to CopyRange to see if this avoids this problem.
grid.Model.CutPaste.CopyRange(selections.ExpandRange(1,1,this.gridDataBoundGrid1.Model.RowCount, this.gridDataBoundGrid1.Model.ColCount));

Hi Clay,
I have found a workaround for the problem I described, thanks.
Are you saying that this is not a bug?
I've attached a very simple project to illustrate what I was describing.
Please let me know if the behavior I am seeing is expected (ie. Cols, Rows or Table ranges are not valid to pass to CutPaste.CopyRange).
-Peter

Thank you for the sample, Peter.
For now, we are treating this as a usage issue, requiring the call to ExpandRange before calling CopyRange if you are using something other than a cell range.
Stefan will look into handling this, but there are some usages of CopyRange internal to the grid where he wants to allow ranges other than Cell ranges. So, until he can work through those particular situations, you'll need to use ExpandRange. We will document this in the next release.