Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 712965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:54:30+00:00 2026-05-14T04:54:30+00:00

I have created data sources from my objects in my project, some of which

  • 0

I have created data sources from my objects in my project, some of which have other objects as members. When I want to bind a some objects to a data grid I would like to display some of the values from the member objects in the data grid as well but the examples I have come across seem to use an entire other datagrid or controls to display these member object values.

How can I combine these values into one data grid? (Preferably without creating a wrapping class)
Can I achieve this with LINQ somehow?

Your help is greatly appreciated.

Thanks

P.S. C# or VB examples will do.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:54:30+00:00Added an answer on May 14, 2026 at 4:54 am

    There’s no clean way to do this in WinForms. You have a couple of options, ranging from easiest to hardest:

    LINQ

    (Specifically here anonymous types).

    You can do something like this:

    dataGridView.DataSource = from x in dataSource
                              select new
                              {
                                  Property = x.Property,
                                  SubProperty = x.ObjectProperty.SubProperty // etc.
                              };
    

    This is by far the simplest approach, but it’s also one-way binding; you cannot update data using this mechanism. This will also give you no design-time support for the grid, as the property names can’t be discovered at design time.

    Wrapper Class

    This, I’m assuming, you’re familiar with. You create a class that wraps your actual data-bound class, passing through the properties and bringing up the “sub-properties” to the class level. For example:

    public string SubProperty
    {
        get { return yourObject.ObjectProperty.SubProperty; }
        set { yourObject.ObjectProperty.SubProperty = value; }
    }
    

    This will give you design-time support for the grid (assuming that you use a BindingSource component and properly set up an object data source for this object) and will allow for two-way binding. It does, however, require that you roll a wrapper class and create every property that you want to bind to.

    Custom Type Descriptor

    This is the most difficult, but it’s also the most flexible, fastest, and cleanest (from an external API perspective). I won’t go into the ins and outs of how to do this in this post, but there are articles available on this. I would link to the MSDN page on custom TypeDescriptors, but it’s a little daunting and extends beyond the scope of what you’re trying to do.

    In short, you create a custom TypeDescriptor class that provides a list of PropertyDescriptor instances. These allow you complete control over the binding experience, rather than relying on reflection (as would be the case in either of the above two cases). This is a non-trivial amount of code, though, so you’ll need to decide if this is what you really want to do before you set out to do it.

    This is a pretty good introduction to the TypeDescriptor class and what it does. What you’re interested here is the PropertyDescriptorCollection. You just need to return a PropertyDescriptor for every property you want to interact with, including nested properties.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application that writes some data to the root folder of
I have some kind of test data and want to create a unit test
I'm working on a project where I have to take data from one source
We have created a control that needs to persist data via the ViewState property
I have created an HttpCookie in order to share data across a subdomain :
in my data layer class I have created a function to manually refresh the
I have a table of paged data, along with a dynamically created pager (server-side
I have a VB application which extracts data and creates 3 CSV files (a.csv,
I have a report created in SSRS in client mode, which is run disconnected:
I have a table of the form CREATE TABLE data { pk INT PRIMARY

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.