I'm trying to get a value from a cell in my datagrid, the code below returns the value from the cell as "System.Windows.Controls.Textblock" whereas I would like the actual value from the cell. The column I am trying to work with is ID in the code.
Any help would be appreciated, thanks!
<sdk:DataGrid AutoGenerateColumns="False" Height="245" HorizontalAlignment="Left" Margin="12,77,0,0" Name="dataIssue" VerticalAlignment="Top" Width="512">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn IsReadOnly="True" Binding="{Binding Path=ID}" Header="ID"/>
<sdk:DataGridTextColumn IsReadOnly="True" Binding="{Binding Path=subject}" Header="Subject"/>
<sdk:DataGridTextColumn IsReadOnly="True" Binding="{Binding Path=project_ID}" Header="Project ID"/>
<sdk:DataGridTextColumn IsReadOnly="True" Binding="{Binding Path=elapsed}" Header="Time"/>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
public void StartTimer(object o, RoutedEventArgs sender)
{
if ((string)timeButton.Content == "Start")
{
string getID = dataIssue.Columns[0].GetCellContent(dataIssue.SelectedItem).ToString();
child.GetID = getID;
watch.Start();
timeButton.Content = "Stop";
}
}
try like this...
TextBlock txtBlock=(TextBlock) myGrid.Columns[1].GetCellContent(myGrid.SelectedItem);
string retrivingtext = txtBlock.Text;
Here myGrid=GridName:
TextBlock= Type of column like
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.