We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Excel like features - copy/paste and multi-level sort

Thread ID:

Created:

Updated:

Platform:

Replies:

99784 Jun 10,2011 08:49 PM UTC Jun 24,2011 09:58 AM UTC WPF 7
loading
Tags: GridControl
Mary Fontana
Asked On June 10, 2011 08:49 PM UTC

I have just started using GridDataControl.

I would like to add the following excel like features.

1) copy one cell and paste value in multiple cells of the same column.
The closest example I saw was in: Excel Like UI Demo.
But I didnt see an example of copy or paste.

2) multi level column sort. I think you can do this by selecting each column. But do you have the Excel Custom Sort popup that lets you define the levels/columns to sort?


Thanks.

















Manikandan [Syncfusion]
Replied On June 14, 2011 03:54 AM UTC

Hi Mary,

Thanks for using Syncfusion Products.

Regarding query 1:

You can achieve your requirement by handling AllowSelection and ListBoxSelectionMode property as follows:

Code Snippet [Xaml]

AllowSelection = "Cell"
ListBoxSelectionMode = "None"

To ignore copying the HeaderText set IncludeHeaderTextOnCopy to false

IncludeHeaderTextOnCopy= "False"

Regarding query 2:

We don't have popup menu support to perform multi levels/columns sort, you can handle multi column sort by holding Cntl and selecting columns to achieve this.

We have prepared a sample for your reference, Please find the sample from the following location

Sample: http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Sample_Obcol-2007884023.zip

Please let us know if this helps.

Regards,
Manikandan



Mary Fontana
Replied On June 14, 2011 09:24 PM UTC


I dont think the solution you showed for my first question provide what I need.
I need a way to paste a value into multiple cells.
For example in excel you can
Copy one cell,
select multiple cells with control key and
paste the value copied into the multiple cells selected.

I attached the excel screen on what I need.

Is there a way to paste a value after selecting multiple cells.

Thanks.





CopyWithMultiPasteExample_d31074d.zip

Ramesh V [Syncfusion]
Replied On June 15, 2011 09:49 AM UTC

Hi,

Sorry for the Inconvenience caused.

We have prepared a sample based on your requirement and you can find the sample under the following location:

Sample : http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=99784-112451743.zip

Please let us know if this helps.

Regards,
Ramesh.V



Mary Fontana
Replied On June 21, 2011 03:42 PM UTC

Thank you for the sample that shows copy and paste to multple values.

I have studied this example, but need to modify the SampleGridControl to use DataGridControl instead.


I am starting with the example:
Sample:< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=WPF_GDC_CheckBox653364425.zip >


I would like to beable to copy a text cell and select multiple cells and then paste the copyied text cell into the other selected cells.

Do I still need to extend the DataGridControl to do this?

or can I start with:
gridControl.AllowSelection = GridSelectionFlags.Multiple;
gridControl.ListBoxSelectionMode = GridSelectionMode.None;
gridControl.Model.Options.ExcelLikeSelectionFrame = true;
gridControl.Model.Options.ExcelLikeCurrentCell = true;

Thanks in advance for your help.



Ramesh V [Syncfusion]
Replied On June 22, 2011 01:25 PM UTC

Hi,

Thanks for your update.

As per you requirement we have modified your sample. Please find the modified sample under the following location.

Sample: http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=WPF_GDC_CheckBox217194046.zip

Please let us know if this helps.

Regards,
Ramesh


Mary Fontana
Replied On June 23, 2011 06:08 PM UTC

Thanks for your example. It works just as I asked.

I also want to extend it so that after you copy a cell value
and then select the entire column
you can paste the clipboard text into the the rows of the column.

If I had applied some filter where only a subset of the rows are showing. How do I get the rows that are visible in the table.

I made the following changes to do column paste:

gridControl.AllowSelection = GridSelectionFlags.Cell | GridSelectionFlags.Multiple | GridSelectionFlags.Column;

then in the method you provided:

void gridControl_PreviewKeyDown(object sender, KeyEventArgs e)
{

...
foreach (GridRangeInfo Range in gridControl.Model.SelectedRanges)
{

if (Range.RangeType == GridRangeInfoType.Cols)
{
int col = Range.Left;
// how do I get the rows that are viewed in table to call

foreach (var Row in ??? visible rows)
this.PasteTextRowCol(Row, vol, buffer);
}

}
else {

// same code as before
}
}
....
}

}


Ramesh V [Syncfusion]
Replied On June 24, 2011 09:58 AM UTC

Hi,

Yes, you can achieve your requirement by applying the following code in your application.

Code snippet [C#]:


void SampleGridControl_PreviewKeyDown(object sender, KeyEventArgs e)
{
bool IsCtrlKey = (e.KeyboardDevice.Modifiers & ModifierKeys.Control) != ModifierKeys.None;
if (IsCtrlKey)
{
if (e.Key == Key.V)
{
if (this.Model.SelectedRanges.Count > 0)
{
string buffer = Clipboard.GetText();
foreach (GridRangeInfo Range in this.Model.SelectedRanges)
{
if (Range.IsCols == true)
{
int Current_Column = Range.Left;
for (int Row = 1; Row < this.Model.RowCount; Row++)
{
this.PasteTextRowCol(Row, Current_Column, buffer);
}
}
else if (Range.IsRows == true)
{
int Current_Row = Range.Top;
for (int Column = 1; Column < this.Model.ColumnCount; Column++)
{
this.PasteTextRowCol(Current_Row, Column, buffer);
}
}
else
{
for (int Row = Range.Top; Row <= Range.Bottom; Row++)
{
for (int Column = Range.Left; Column <= Range.Right; Column++)
{
this.PasteTextRowCol(Row, Column, buffer);
}
}
}
}
e.Handled = true;
}
}
}
}


private bool PasteTextRowCol(int rowIndex, int colIndex, string text)
{
bool state = false;
foreach (GridControlBase grid in this.Model.Views)
{
if (grid != null)
{
grid.CurrentCell.MoveTo(rowIndex, colIndex);
GridStyleInfo style = this.Model[rowIndex, colIndex];
state = style.ApplyFormattedText(text, GridCellBaseTextInfo.PasteText);
grid.CurrentCell.BeginEdit();
grid.CurrentCell.Deactivate();
}
}

return state;
}
And also we have modified your sample as per your requirement please find the modified sample under the following location.

Sample: http://www.syncfusion.com/uploads/redirect.aspx?file=Multicellpaste GDC_89ac4b5f.rar&team=testingftp

Please let us know if this helps.

Regards,
Ramesh



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;