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 625271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:17:30+00:00 2026-05-13T19:17:30+00:00

I have a DataGridView control and I want to populate it with data. I

  • 0

I have a DataGridView control and I want to populate it with data.

I use DataSource property

// dgvDealAsset is DataGridView
        private void DealAssetListControl_Load(object sender, EventArgs e)
        {
            dgvDealAssets.AutoGenerateColumns = false;
            dgvDealAssets.DataSource = DealAssetList.Instance.Values.ToList();
}

Now problem number one. The class of my collection does not contain only simple types that I can map to columns using DataPropertyName. This is the class that is contained in collection.

class MyClass
{
  public String Name;
  MyOtherClass otherclass;
}

class MyOtherClass
{
 public String Name;
}

Now I am binding properties of MyClass to columns

col1.DataPropertyName = "Name"  // Ok 
col2.DataPropertyName = "otherclass" // Not OK - I will have empty cell

The problem is that I want to display otherclass.Name field. But if I try to write

col2.DataPropertyName = "otherclass.Name" 

I get empty cell.

I tried to manually set the column

private void DealAssetListControl_Load(object sender, EventArgs e)
{
    dgvDealAssets.AutoGenerateColumns = false;
    dgvDealAssets.DataSource = DealAssetList.Instance.Values.ToList();

// iterate through rows and set the column manually
        foreach (DataGridViewRow row in dgvDealAssets.Rows)
        {
            row.Cells["Column2"].Value = ((DealAsset)row.DataBoundItem).otherclass.Name;
        }

But this foreach cycle takes about minute to complete (2k elements). How to solve this problem?

  • 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-13T19:17:31+00:00Added an answer on May 13, 2026 at 7:17 pm

    DataGridView doesn’t support databinding to child properties. For more info, check this post

    I like the solution that uses the CellFormatting event.

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

Sidebar

Related Questions

I have a dategridview. It has UserDeletingRow event private void dataGridVWTransactions_UserDeletingRow( object sender, DataGridViewRowCancelEventArgs
In my application I have a DataGridView control that displays data for the selected
I have a DatagridView control on a Windows form. It's selectionMode property is set
I want to use a tab control to switch between sets of data displayed
I have a custom DataGridView control and want to set the text format for
My DataGridView control currently sorts using the Sort property of the bound data, but
I have a DataGridView control in a winforms app that I'm working on. The
I'm using c#2.0 and WinForms. I have a datagridview control, unbound, loading small amounts
I have a WinForms application with a DataGridView control and a column of DataGridViewButtonCell
I have encountered a rather nasty problem with the DataGridView control (Windows.Forms, .NET Framework

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.