Copy text from TextBox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Dvali

    #1

    Copy text from TextBox

    How can I cut/copy/paste text from/into textbox using clipboard from my
    code?


  • Angel J. Hernández M.

    #2
    Re: Copy text from TextBox

    You can use the Clipboard class. For example:

    Copying
    ******
    Clipboard.SetDa taObject(MyText box.SelectedTex t, true);

    Cutting
    ******
    Clipboard.SetDa taObject(MyText box.SelectedTex t, true);
    MyTextbox.Text = string.Empty;

    Pasting
    ******
    IDataObject data = Clipboard.GetDa taObject();

    if (data.GetDataPr esent(DataForma ts.Text))
    MyTextBox.Text = (string) data.GetData(Da taFormats.Text) ;

    Regards,


    --
    Angel J. Hernández M.
    MCP - MCAD - MCSD - MCDBA







    "David Dvali" <david_dvali@ho tmail.com> wrote in message
    news:u5g53YlVFH A.1148@tk2msftn gp13.phx.gbl...[color=blue]
    > How can I cut/copy/paste text from/into textbox using clipboard from my
    > code?
    >[/color]


    Comment

    • Alan Pretre

      #3
      Re: Copy text from TextBox

      "David Dvali" <david_dvali@ho tmail.com> wrote in message
      news:u5g53YlVFH A.1148@tk2msftn gp13.phx.gbl...[color=blue]
      > How can I cut/copy/paste text from/into textbox using clipboard from my
      > code?[/color]

      The textbox control has Copy(), Cut(), and Paste() methods.

      -- Alan


      Comment

      Working...