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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:57:01+00:00 2026-05-13T01:57:01+00:00

So I have a datagridview. Normally I can create a bindinglist of my object

  • 0

So I have a datagridview.

Normally I can create a bindinglist of my object and it will display all the data and colums correctly

E.g

BindingList<Customer> CustomerList = new BindingList<Customer>();
myDataGridView.DataSource = CustomerList;

And it will display a column for each property in Customer which has a getter.
It will also display a row for each object.

Perfect result.

Now in my current scenario, I have these objects:

public class Reservedele
{
    public int Rnr { get; private set;}
    public string Navn { get; private set;}
    public double Pris { get; private set;}
    public string Type { get; private set;}

    public Reservedele(int rnr, string navn, double pris, string type)
    {
        Rnr = rnr;
        Navn = navn;
        Pris = pris;
        Type = type;
    }
}
public class IndkøbsKurvReservedele
{
    public Reservedele Reservedel  { get; private set;}
    public int Antal { get; private set; }
    public double Pris { get; private set; }

    public IndkøbsKurvReservedele(Reservedele reservedel, int antal, double pris)
    {
        Reservedel = reservedel;
        Antal = antal;
        Pris = pris;
    }
}

So if I do this:

BindingList<IndkøbsKurvReservedele> ReserveDeleListeIndKøbsKurv = new BindingList<IndkøbsKurvReservedele>();
myDataGridView.DataSource = ReserveDeleListeIndKøbsKurv;

It won’t work 🙁
The error is that the datagridview shows:

  • The object itself
  • Antal
  • Pris

Example:
alt text

How can I instruct the datagridview that I want it to have the properties from Reservedel followed by the properties in IndkøbsKurvReservedele as headers??

For reference, Reservedel means “spare parts” and IndkøbsKurvReservedel means something like “ShoppingBasketOfSpareParts”.
Antal means “amount” as in how many there is.
Sorry for the foreign variable naming.

EDIT: I have another question: How can I make the Rnr property not to show up as a column?

  • 1 1 Answer
  • 4 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-13T01:57:01+00:00Added an answer on May 13, 2026 at 1:57 am

    This is my solution:

    public class IndkøbsKurvReservedele
    {
        //public Reservedele Reservedel  { get; private set;}
        private int Rnr;
        public string Navn { get; private set; }
        public double Pris { get; private set; }
        public string Type { get; private set; }
        public int Antal { get; private set; }
        public double SPris { get; private set; }
    
        public IndkøbsKurvReservedele(Reservedele reservedel, int antal, double sPris)
        {
            Rnr = reservedel.Rnr;
            Navn = reservedel.Navn;
            Pris = reservedel.Pris;
            Type = reservedel.Type;
            Antal = antal;
            SPris = sPris;
        }
        public int HenrReservedelsNummer()
        {
            return Rnr;
        }
    }
    

    If anyone creates a better. I will accept theirs instead.

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

Sidebar

Related Questions

hi i have datagridview name data1, and binding data to data1 from database, when
I have a DataGridview that displays the data and a TextBox that allows me
I have datagridview on my winform and you can add and delete items from
I have a DataGridView that displays data from a MS Access database. I'm using
I have a DataGridView that I want to use to store generic data. I
I have a DataGridView whose datasource is a BindingList. MyObj has a few nullable
I have datagridview which fills data from database, there are columns where I have
I have a DataGridView for which I want to create an event handler for
I have DataGridView which contains two ComboBox columns. The second ComboBox will be filled
I have a DataGridView with all columns set to Automatic sort mode. When I

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.