HowTo paste multiline text in richtext cell

Hi,

I want to paste multiline text from the clipboard into a single richtext cell of a GridControl. I took the RichTextCells sample from 4.2.0.60. In Notepad I wrote a text with four lines and copied it into the clipboard.
In the GridControl I marked the cell A3:E3 without dropdown. Then I pressed CTRL+V. The text is written in Cells A3, A4, A5 and A6.
How can I configure the grid that all multiline text is written in A3?

Regards
Christian

2 Replies

AD Administrator Syncfusion Team November 7, 2006 10:50 AM UTC

Hi Christian,

You can handle the ClipBoardPaste event and can control the pasting yourself. Here is a code snippet to paste multiline text in a richtext cell.

private void grid_ClipboardPaste(object sender, Syncfusion.Windows.Forms.Grid.GridCutPasteEventArgs e)
{
DataObject data = (DataObject) Clipboard.GetDataObject();
if(data.GetDataPresent(DataFormats.Text))
{
GridControl grid = this.gridControl1 as GridControl;
GridCurrentCell cc = grid.CurrentCell;
if( cc != null
&& cc.Renderer != null
&& cc.Renderer.CurrentStyle.CellType == "RichText")
{
string s = (string)data.GetData(DataFormats.Text);
grid.Model[cc.RowIndex,cc.ColIndex].Text = s;
e.Handled = true;
}
}
}

Best Regards,
Haneef


CL Christian Lützenkirchen November 7, 2006 01:26 PM UTC

Hi Haneef,

it works fine. Thank you for your help.

Best Regards,
Christian

Loader.
Up arrow icon