Hi Raymond,
1) I tried adding copying and pasting a lot of text in the DotNetEdit sample that ships with Essential Edit. Here is a
screenshot with nearly 200,000 characters in a single line.
2) Here is how you can take care of the paste issue:
a) To catch Ctrl-V, so that it is not processed by the EditControl''s Context-Menu:
private void Form1_Load(object sender, System.EventArgs e)
{
this.editControl1.Multiline = false;
ContextMenu cm = this.editControl1.ContextMenu;
foreach(MenuItem mi in cm.MenuItems)
{
this.RemoveShortcutInEditControl(mi);
}
}
private void RemoveShortcutInEditControl(MenuItem miParent)
{
// Remove CtrlV shortcut.
if(miParent.Shortcut == Shortcut.CtrlV)
miParent.Shortcut = Shortcut.None;
// Parse through the children recursively.
foreach(MenuItem mi in miParent.MenuItems)
{
this.RemoveShortcutInEditControl(mi);
}
}
b) To check the length of the text that is being pasted:
private void editControl1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if((e.Control)&&e.KeyCode==Keys.V)
{
IDataObject data = Clipboard.GetDataObject();
if(data.GetDataPresent(DataFormats.Text))
{
string text = (String)data.GetData(DataFormats.Text);
if (text.Length>9999)
{
MessageBox.Show("Char count exceeded, cannot paste");
}
else
this.editControl1.Paste();
}
}
}
Regards
Arun