AD
Administrator
Syncfusion Team
November 16, 2007 12:01 PM UTC
The paste support that you are seeing is inherited through GridControlBase (the TableControl property in the GridGroupingControl). This support pastes text using tabs to mark new columns and newlines to mark new rows (as if the text came from rows and columns in Excel). So, the newlines in your Doc text are being pasted across multiple rows in the TableControl.
One way to avoid this behavior is to handle the TableCOntrolCurrentCellKeyDown event and do the paste yourself there. Here is a little code showing how.
//subcribe to the event
this.gridGroupingControl1.TableControlCurrentCellKeyDown += new GridTableControlKeyEventHandler(gridGroupingControl1_TableControlCurrentCellKeyDown);
//the handler
void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{
if (e.Inner.Control && e.Inner.KeyCode == Keys.V)
{
if (e.TableControl.CurrentCell.IsEditing)
{
GridTextBoxCellRenderer renderer = e.TableControl.CurrentCell.Renderer as GridTextBoxCellRenderer;
if (renderer != null)
{
if (Clipboard.ContainsText())
{
string s = Clipboard.GetText();
renderer.TextBox.SelectedText = s;
e.Inner.Handled = true;
}
}
}
}
}
PR
Prem
November 21, 2007 03:20 PM UTC
Thanks Clay.
That worked great.
Thanks again!!
Prem
>The paste support that you are seeing is inherited through GridControlBase (the TableControl property in the GridGroupingControl). This support pastes text using tabs to mark new columns and newlines to mark new rows (as if the text came from rows and columns in Excel). So, the newlines in your Doc text are being pasted across multiple rows in the TableControl.
One way to avoid this behavior is to handle the TableCOntrolCurrentCellKeyDown event and do the paste yourself there. Here is a little code showing how.
//subcribe to the event
this.gridGroupingControl1.TableControlCurrentCellKeyDown += new GridTableControlKeyEventHandler(gridGroupingControl1_TableControlCurrentCellKeyDown);
//the handler
void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{
if (e.Inner.Control && e.Inner.KeyCode == Keys.V)
{
if (e.TableControl.CurrentCell.IsEditing)
{
GridTextBoxCellRenderer renderer = e.TableControl.CurrentCell.Renderer as GridTextBoxCellRenderer;
if (renderer != null)
{
if (Clipboard.ContainsText())
{
string s = Clipboard.GetText();
renderer.TextBox.SelectedText = s;
e.Inner.Handled = true;
}
}
}
}
}