Answered by:
Read current cell value in Wpf datagrid

Question
-
Hai
Purpose: To make custom column to enter only decimals (inlcuding period once).
I use Code below to read current cell value from Datagrid in PreviewKeyDown.
and I am getting the value also.The content received is like this
"System.Windows.Controls.DataGridCell:" then cell text. But I want only the Content of cell.
Please tell me how to get this and I want this in PreviewKeyDown event or OnPreviewTextInput.var cellInfo = Dgv.SelectedCells[0]; var cellContent = GetDataGridCell(cellInfo); string xx = Convert.ToString(cellContent); MessageBox.Show(Convert.ToString(xx)); public DataGridCell GetDataGridCell(DataGridCellInfo cellInfo) { var cellContent = cellInfo.Column.GetCellContent(cellInfo.Item); if (cellContent != null) return (DataGridCell)cellContent.Parent; return null; } void OnPreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e) { e.Handled = new Regex("[^0-9.]").IsMatch(e.Text); }
I want to check weather period exist more than once. Or is there any alternate.
Thanks
programmer
- Moved by Dave PatrickMVP Saturday, October 15, 2016 12:56 PM
Saturday, October 15, 2016 8:40 AM
Answers
-
They'll help you over here.
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.
- Edited by Dave PatrickMVP Saturday, October 15, 2016 12:56 PM
- Proposed as answer by Mike Laughlin Sunday, October 16, 2016 11:47 PM
- Marked as answer by Just Karl Sunday, October 30, 2016 3:27 PM
Saturday, October 15, 2016 12:55 PM
All replies
-
They'll help you over here.
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.
- Edited by Dave PatrickMVP Saturday, October 15, 2016 12:56 PM
- Proposed as answer by Mike Laughlin Sunday, October 16, 2016 11:47 PM
- Marked as answer by Just Karl Sunday, October 30, 2016 3:27 PM
Saturday, October 15, 2016 12:55 PM -
Hai
Sorry I couldn't find any solution
programmer
Tuesday, October 18, 2016 11:41 AM -
This is "where is" forum for direction on where best to ask questions. I didn't expect an answer to already be there. I'd re-ask your question over there.
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.Tuesday, October 18, 2016 12:09 PM