Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. DataGrid won't detect CTRL + C

DataGrid won't detect CTRL + C

Scheduled Pinned Locked Moved WPF
wpfcsharphelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mc_Topaz
    wrote on last edited by
    #1

    I have a WPF applicaiton where the MainWindow class have <Window.CommandBindings> and <Window.InputBindings> so I can use CTRL + X, CTRL + C and CTRL + V commands. The MainWindow contains a DataGrid where I want to select a row and copy the data in the row with the CTRL + C command. When a row is selected in the DataGrid the CTRL + C command stops working. CTRL + X and CTRL + V are still detected. I have managed to reproduce this problem. Just copy and paste the code below, it should compile and run on the go. Then do the following: Press either CTRL + X, CTRL + C or CTRL + V you will get a popup window saying what command was activated. Select a row in the DataGrid and then run CTRL + C. Nothing will happen. MainWindow.XAML code

                    <Setter Property="BorderThickness" Value="0" />
                    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    

    MainWindow.cs code

    V H 2 Replies Last reply
    0
    • M Mc_Topaz

      I have a WPF applicaiton where the MainWindow class have <Window.CommandBindings> and <Window.InputBindings> so I can use CTRL + X, CTRL + C and CTRL + V commands. The MainWindow contains a DataGrid where I want to select a row and copy the data in the row with the CTRL + C command. When a row is selected in the DataGrid the CTRL + C command stops working. CTRL + X and CTRL + V are still detected. I have managed to reproduce this problem. Just copy and paste the code below, it should compile and run on the go. Then do the following: Press either CTRL + X, CTRL + C or CTRL + V you will get a popup window saying what command was activated. Select a row in the DataGrid and then run CTRL + C. Nothing will happen. MainWindow.XAML code

                      <Setter Property="BorderThickness" Value="0" />
                      <Setter Property="FocusVisualStyle" Value="{x:Null}" />
      

      MainWindow.cs code

      V Offline
      V Offline
      Vincent Beek
      wrote on last edited by
      #2

      You are right that you won't get the MessageBox but it is handeling the copy command. Just add a TextBox and perform a paste. So I think the event is set to e.Handled before your event.

      M 1 Reply Last reply
      0
      • V Vincent Beek

        You are right that you won't get the MessageBox but it is handeling the copy command. Just add a TextBox and perform a paste. So I think the event is set to e.Handled before your event.

        M Offline
        M Offline
        Mc_Topaz
        wrote on last edited by
        #3

        I'm confused about your answer: * What do you mean by "add a TextBox". * Why should I use a TextBox to solve this? * Where should I add a TextBox? * What has the paste command to do with this? I only want the CTRL + C command to be detected in the MainWindow when a row is selected in the DataGrid. This has nothing to do what I want to copy and when I want to paste it.

        V 1 Reply Last reply
        0
        • M Mc_Topaz

          I'm confused about your answer: * What do you mean by "add a TextBox". * Why should I use a TextBox to solve this? * Where should I add a TextBox? * What has the paste command to do with this? I only want the CTRL + C command to be detected in the MainWindow when a row is selected in the DataGrid. This has nothing to do what I want to copy and when I want to paste it.

          V Offline
          V Offline
          Vincent Beek
          wrote on last edited by
          #4

          That's what I am trying to tell you. In your current code it is detected. When you press CTRL+C the grid row is being copied. The textbox is just for testing. After the copy you can past your grid row there and see for your self that a CRTL+C copy was made.

          1 Reply Last reply
          0
          • M Mc_Topaz

            I have a WPF applicaiton where the MainWindow class have <Window.CommandBindings> and <Window.InputBindings> so I can use CTRL + X, CTRL + C and CTRL + V commands. The MainWindow contains a DataGrid where I want to select a row and copy the data in the row with the CTRL + C command. When a row is selected in the DataGrid the CTRL + C command stops working. CTRL + X and CTRL + V are still detected. I have managed to reproduce this problem. Just copy and paste the code below, it should compile and run on the go. Then do the following: Press either CTRL + X, CTRL + C or CTRL + V you will get a popup window saying what command was activated. Select a row in the DataGrid and then run CTRL + C. Nothing will happen. MainWindow.XAML code

                            <Setter Property="BorderThickness" Value="0" />
                            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
            

            MainWindow.cs code

            H Offline
            H Offline
            Hi I am Kevin
            wrote on last edited by
            #5

            What is your silverlight version ? Because in the version 3 is not possible only in the 4 and the next versions

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups