المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Cut,Copy ,Paste Problem...



C# Programming
08-12-2009, 05:31 PM
Private StringBuilder sb=null

private void CutCopyPaste(bool Cut, bool Copy, bool Paste)
{
foreach (Form f in this.MdiChildren)
{
if (f.ContainsFocus)
{
foreach (Control c in f.Controls)
{
if (c.Focused)
{
if (c.GetType() != typeof(Label))
{
if (Cut)
{
sb.Append(c.Text);
c.Text = "";
}
else if (Copy)
sb.Append(c.Text);
else if (Paste)
c.Text = sb.ToString();
break;
}
}
}
}
}
}



private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
sb = null;
sb = new StringBuilder();
CutCopyPaste(false, true, false);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
if (sb != null)
CutCopyPaste(false, false, true);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void cutToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
sb = null;
sb = new StringBuilder();
CutCopyPaste(true, false, false);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

It is the complete code for cut copy and paste but if we take textbox inside the container like groupbox,panel etc. its not working ...and i want also include the feature Undo and SelectAll...how can i do this...