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. how can i get cell value from wpf datagrid?

how can i get cell value from wpf datagrid?

Scheduled Pinned Locked Moved WPF
questioncsharpwpf
4 Posts 4 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

    how can i get cell value from wpf datagrid? this code, wich used to validate data (email adress) from datagrid private void button2_Click(object sender, RoutedEventArgs e) { Validator v =new Validator();// class... String item = dgv1.CurrentCell.Item.ToString(); if (v.validate(item)) { MessageBox.Show("ok"); } else { MessageBox.Show("no"); } }

    M A 2 Replies Last reply
    0
    • M MemberDotNetting

      how can i get cell value from wpf datagrid? this code, wich used to validate data (email adress) from datagrid private void button2_Click(object sender, RoutedEventArgs e) { Validator v =new Validator();// class... String item = dgv1.CurrentCell.Item.ToString(); if (v.validate(item)) { MessageBox.Show("ok"); } else { MessageBox.Show("no"); } }

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Wake UP - you need to do it right, work with the data not the control. You have a collection bound to the datagrid and you should have a selected object (an item of the collection) validate the data in the selected object not the control content.

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • M MemberDotNetting

        how can i get cell value from wpf datagrid? this code, wich used to validate data (email adress) from datagrid private void button2_Click(object sender, RoutedEventArgs e) { Validator v =new Validator();// class... String item = dgv1.CurrentCell.Item.ToString(); if (v.validate(item)) { MessageBox.Show("ok"); } else { MessageBox.Show("no"); } }

        A Offline
        A Offline
        Abhinav S
        wrote on last edited by
        #3

        A similar question was asked before. See the answers given here[^].

        S 1 Reply Last reply
        0
        • A Abhinav S

          A similar question was asked before. See the answers given here[^].

          S Offline
          S Offline
          Satish Pai
          wrote on last edited by
          #4

          Hi, I think if u are assigning a Observable collection to a datagrid, & the binding are 2 way mode then changes done on any object will be reflected on both. so need the cell value. its like this ObservableCollection s = new ObservableCollectio(); datagrid1.ItemSource = s; s[0].Columnname 0 will be the row, in this way u can access the cell value. Regads, Satish Pai

          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