How to get the column in runtime?
-
if (true == ((List)DG.ItemsSource).Any(el =>; el.Name == CurrentInput))
{
MessageBox.Show("Looking in column: " + ????? );
}I don' t want to be always in the column Name, but in which is current. DG is the DataGrid. How?
-
if (true == ((List)DG.ItemsSource).Any(el =>; el.Name == CurrentInput))
{
MessageBox.Show("Looking in column: " + ????? );
}I don' t want to be always in the column Name, but in which is current. DG is the DataGrid. How?
I don't understand the question. The columns are generally bound to some property in the data object for the row (the collection of these data items is the datagrid's ItemsSource). The datagrid's SelectedItem property will give you that object.
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
if (true == ((List)DG.ItemsSource).Any(el =>; el.Name == CurrentInput))
{
MessageBox.Show("Looking in column: " + ????? );
}I don' t want to be always in the column Name, but in which is current. DG is the DataGrid. How?
- You don't need "true ==" 2) You don't need a semicolon after the => in your anonymous function Anyway... You should be using FirstOrDefault() instead of Any(). That'll return the item that satisfied the condition, instead of just letting you know that such an item exists. For example:
Person p = lstPeople.FirstOrDefault(a => a.Age > 18);
if (p != null)
{
//...
}Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)