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. passing data betwen tabitem and datagrid

passing data betwen tabitem and datagrid

Scheduled Pinned Locked Moved WPF
csharpdotnetwpf
4 Posts 2 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
    MemberDotNetting
    wrote on last edited by
    #1

    Hi, i have 2 tabitem, each one cotain a wpf gdatagrid i want to pass data from grid1 in tabitem1 to grid2 in tabintem2 when i click on tab item2 or on boutton. i tried this code but i get exception: L'élément possède déjà un parent logique. Il doit être détaché de l'ancien parent avant d'être attaché au nouveau.

    private void btnValidate_Click(object sender, RoutedEventArgs e)
    {
    for (int j = 0; j < i - 1; j++)
    {
    TextBlock x = dgrecep.Columns[0].GetCellContent(dgrecep.Items[j]) as TextBlock;// GRID1 TABITEM1
    if (x != null)
    {
    if (v.validate(x.Text))
    {

                       dgrecep2.Items.Add(dgrecep.Columns\[0\].GetCellContent(dgrecep.Items\[j\]));//GRID2 TABITEM2
                    }
                    else
                    {
                        MessageBox.Show("non valide");
                    }
    
    P 1 Reply Last reply
    0
    • M MemberDotNetting

      Hi, i have 2 tabitem, each one cotain a wpf gdatagrid i want to pass data from grid1 in tabitem1 to grid2 in tabintem2 when i click on tab item2 or on boutton. i tried this code but i get exception: L'élément possède déjà un parent logique. Il doit être détaché de l'ancien parent avant d'être attaché au nouveau.

      private void btnValidate_Click(object sender, RoutedEventArgs e)
      {
      for (int j = 0; j < i - 1; j++)
      {
      TextBlock x = dgrecep.Columns[0].GetCellContent(dgrecep.Items[j]) as TextBlock;// GRID1 TABITEM1
      if (x != null)
      {
      if (v.validate(x.Text))
      {

                         dgrecep2.Items.Add(dgrecep.Columns\[0\].GetCellContent(dgrecep.Items\[j\]));//GRID2 TABITEM2
                      }
                      else
                      {
                          MessageBox.Show("non valide");
                      }
      
      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Why on earth are you doing this via code behind? You really need to read up on MVVM, and judging by the number of questions you have posted in this forum, I would suggest that you need to read a basic book on WPF, such as Adam Nathan's excellent WPF Unleashed.

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      M 1 Reply Last reply
      0
      • P Pete OHanlon

        Why on earth are you doing this via code behind? You really need to read up on MVVM, and judging by the number of questions you have posted in this forum, I would suggest that you need to read a basic book on WPF, such as Adam Nathan's excellent WPF Unleashed.

        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

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

        I am a student and I'm doing my final year project and this project is the first work with WPF, I downloaded a book and I make every effort to learn because I believe in that "le difficile c'est le chemin" and I asked a lot of questions because I have a month to develop my application also it is not MVVM because company demanded another architecture...thank you

        P 1 Reply Last reply
        0
        • M MemberDotNetting

          I am a student and I'm doing my final year project and this project is the first work with WPF, I downloaded a book and I make every effort to learn because I believe in that "le difficile c'est le chemin" and I asked a lot of questions because I have a month to develop my application also it is not MVVM because company demanded another architecture...thank you

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          I find it hard to believe that a company would demand no architecture whatsoever. What you are doing is code behind and is not suited to solving the problem you are trying to solve. Now is the time for you to embrace the right way to do it.

          *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

          CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

          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