how can i get cell value from wpf datagrid?
-
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"); } }
-
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"); } }
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
-
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"); } }
-
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