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

Capturing user selected text inside a cell for copy/cut/paste operation.

Thread ID:

Created:

Updated:

Platform:

Replies:

106016 Dec 4,2012 04:08 PM UTC Dec 17,2012 11:27 AM UTC Windows Forms 5
loading
Tags: GridControl
Leo Rakita
Asked On December 4, 2012 04:08 PM UTC

I am new to Syncfusion so I apologize in advance if this question has already been asked and answered elsewhere. If it has perhaps some one could point me toward that thread. 

I am currently working on a a bug in an application that uses Syncfusion.Windows.Forms.Grid event library. As the application is currently written, if the user selects a portion of the text within a given cell (lets call it source cell) selects "Copy" or "Cut", than selects/highlights some portion of text in another cell (destination cell), and clicks "Paste", the entire content of the source cell is Copied/Cut into the destination cell. The desired effect is to perform the Copy/Cut operation only with the text that the user selected/highlighted and to not overwrite the entire contents of the destination cell, but only the portion that was highlighted. The desired behavior would be analogous to regular Microsoft Excel operation.
 
Does Syncfusion keep track of user highlighted text within a cell? If, so how can I access it? I am currently using Syncfusion Essentail Studio v9.3.0.61.

Thank you in advance for your help.

- Leo


Arun Kumar V [Syncfusion]
Replied On December 7, 2012 06:23 AM UTC

Hi Leo,

Thanks for your interest in Syncfusion products.

Query:

Does Syncfusion keep track of user highlighted text within a cell? If, so how can I access it?

Yes, you can keep track of the selected text by customizing the following events.

1.       CurrentCellStartEditing event.

2.       TextBox_MouseUp event.

Please refer to the following code snippet and the sample file.

Code snippet:

void gridDataBoundGrid1_CurrentCellStartEditing(object sender, CancelEventArgs e)

{

GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;

if (cc.Renderer is GridTextBoxCellRenderer)

{

GridTextBoxCellRenderer rend = cc.Renderer as GridTextBoxCellRenderer;

rend.TextBox.MouseUp += new MouseEventHandler(TextBox_MouseUp);

}

}

Using the mouseup event, you will get the selected text .

void TextBox_MouseUp(object sender, MouseEventArgs e)

{

TextBox text = sender as TextBox;

if (text.SelectionLength > 0)

{

Console.WriteLine(text.SelectedText);

}

}

Sample file: http://www.syncfusion.com/downloads/Support/DirectTrac/99890/99890_SelectedText653111008.zip

Please let me know if you have any other concerns.

Regards,

Arun.


Leo Rakita
Replied On December 13, 2012 08:18 PM UTC

Hi Arun, I just realized I asked tthe question somewhat incorrectly. I assumed the project I am working on uses Syncfusion Grid element and your sample reflects that:

"using Syncfusion.Windows.Forms.Grid;
"

However when I look at the mainForm of the application I am working on, 
I don't see the Grid element, rather I see the tools element:

"using Syncfusion.Windows.Forms.Tools;"
Should I ask my question in a different part of the forum, or does this not change anything? Sorry for the confusion.

Thanks,
Leo

Vinish Kumar K [Syncfusion]
Replied On December 14, 2012 12:08 PM UTC

Hi Leo Rakita,

 

Thanks for your update.

 

The last update of yours is un cleared for us. We can’t find what issue you faced.  If you have faced the same issue, please provide the sample code or project file which is reproduce the issue in your end. It will helps us to reproduce the issue and provide better solution.

 

If you have any new queries, please create new forum query. Please let me know if you have further concerns.

 

Regards,

Vinish.


Leo Rakita
Replied On December 14, 2012 09:16 PM UTC

Sorry for the confusion, perhaps this will clarify....


Currently the way the application is written, there is an action handler: ActionHandlerCutCopyPaste.cs

Within this class there is a block of code that is triggered when user makes a selection in the application and clicks "COPY": if (type.Equals(PTConstants.ACTION_COPY))
Within this if statement, I make a call to a method I am working on implementing:
String userSelectedText = mainForm._pdd.getCurrentUserSelectedText();
_pdd is an instance of PrimaryDataDisplay class which has a GridControl Element:
private Syncfusion.Windows.Forms.Grid.GridControl _gridPDD = null; 

In the PrimaryDataDisplay.cs class I am implementing 

  public String getCurrentUserSelectedText()
        {
            
            
 
            // Retrieve the old and new values of a cell.
            GridCurrentCell cc = this._gridPDD.CurrentCell;
            string newValue = cc.Renderer.ControlText;
            string oldValue = this._gridPDD[cc.RowIndex, cc.ColIndex].Text;
 
 
   
            return newValue;
        }
 
newValue string stores the entire value within current cell (cc). Is there a way to 
retrieve only the portion of text the user has selected? I don't see a method 
associated with GridCurrentCell that would allow me to do that. 

Thanks,

Leo

Arun Kumar V [Syncfusion]
Replied On December 17, 2012 11:27 AM UTC

Hi Leo,

Thanks for the update.

Query:

Is there a way to

retrieve only the portion of text the user has selected?

The sample file and code I had given above itself can be used for getting the cell partial text. I had attached two forum link’s please refer to it and let me know if the reported behavior had been solved.

Forum Link : http://www.syncfusion.com/support/forums/grid-windows/67771

KB link : http://www.syncfusion.com/support/kb/606

Please let me know if you have any other concerns.

 

Regards,

Arun.


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

;