Created
July 24, 2016 23:38
-
-
Save RicardoACS/41569fb25c5dd3b6f4792f38c6004fc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<DataGridRow> obtenerDataGridRows(DataGrid grid) | |
{ | |
var itemsSource = grid.ItemsSource as IEnumerable; | |
if (null == itemsSource) yield return null; | |
foreach (var item in itemsSource) | |
{ | |
var row = grid.ItemContainerGenerator.ContainerFromItem(item) as DataGridRow; | |
if (null != row) yield return row; | |
} | |
} | |
private void dataGrid_Trips_SelectionChanged(object sender, SelectionChangedEventArgs e) | |
{ | |
try | |
{ | |
DataTable dt = new DataTable(); | |
dt = ((DataView)dataGrid_Trips.ItemsSource).ToTable(); | |
var row_list = obtenerDataGridRows(dataGrid_Trips); | |
foreach (DataGridRow single_row in row_list) | |
{ | |
if (single_row.IsSelected == true) | |
{ | |
textboxSearchClient.Text = dt.Rows[single_row.GetIndex()].ItemArray[0].ToString(); | |
} | |
} | |
} | |
catch (Exception) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment