Eric Snyder - 2019-02-12

I have used the ObjectListView correctly. Kudos for the great idea and work!

I am pulling data from tables to feed to the control. When I do a double click on a record I need a value for one of the controls. From what I can tell I need to cast "object sender" to a usable form. I can do the following reflection in the event handler. Is there a better, more readable, understandable way?

Pulling data by Linq (Entity Framework):

        private void LoadFirstParts()
        {
            using (var context = new Entities())
            {
                var query = 
                    from t in context.Tools
                    join f in context.FirstParts on t.ToolID equals f.ToolID
                    orderby f.FirstPartID ascending
                    select new { ToolNumber = t.ToolNumber, Description = t.Description, FileName = f.DateTime };

                objectListView1.SetObjects(query);
            }
        }

Use at the doubleClick event handler:

       private void OpenFirstPartImage(object sender, EventArgs e)
        {
            BrightIdeasSoftware.ObjectListView s = (BrightIdeasSoftware.ObjectListView)sender;
            var d = s.SelectedObject;
            System.Reflection.PropertyInfo pi = d.GetType().GetProperty("FileName");
            String name = (String)(pi.GetValue(d, null));
            Console.WriteLine(name);
        }