Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. How to get the column in runtime?

How to get the column in runtime?

Scheduled Pinned Locked Moved WPF
tutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sadas232341s
    wrote on last edited by
    #1

    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?

    M I 2 Replies Last reply
    0
    • S sadas232341s

      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?

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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:

      1 Reply Last reply
      0
      • S sadas232341s

        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 Offline
        I Offline
        Ian Shlasko
        wrote on last edited by
        #3
        1. 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)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups