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
  • 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-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

How can I have a datagridview that will autogenerate a textbox instead of a
I have a datagridview where the users can select which subset of columns to
In my application I have a DataGridView control that displays data for the selected
I have a DataGridView column header. When I click that header, the data is
I have DataGridView and when I display export to excel sheet button following error
I have datagridview with checkbox column, and the checkbox within the column can be
hi i have datagridview name data1, and binding data to data1 from database, when
I have a DataGridView with one DataGridViewComboBoxColumn in my WinForms application. I need to
I have a DataGridView with its datasource set to a generic list of custom
I have a DataGridView that I want to query using Linq (C# WinForm). 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.