TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ron
NA
44
64.4k
Datagrid current Row/Value
Feb 28 2012 12:12 PM
This seems like a simple operation, but the solution has so far eluded me. I have a datagrid (I'm working in WPF) that is displaying data properly. I have some code in the previewkeydown event that I'd like to give me the value of the first cell in the grid that is currently selected. The following code works OK:
public static class DataGridHelper
{
public static DataGridCell GetCell(DataGridCellInfo dataGridCellInfo)
{
var cellContent = dataGridCellInfo.Column.GetCellContent(dataGridCellInfo.Item);
return (DataGridCell)cellContent.Parent;
}
}
I display the cell content in a textbox using:
DataGridCell cell = DataGridHelper.GetCell(MyDataGrid.SelectedCells[0]);
txtMisc.Text = cell.ToString();
This is what displays:
System.Windows.Controls.DataGridCell: 1245
I only need the 1245
Is there a way to remove everything except the 1245?
Reply
Answers (
3
)
C# visual studio help needed
Passing values from one form to another form