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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:35:45+00:00 2026-06-08T00:35:45+00:00

Sometimes, I usually create a class with the type of data I want like

  • 0

Sometimes, I usually create a class with the type of data I want like this:

public class message{
    private string subject { get; set; }
    private string message { get; set; }
}

This way, I can bind a List<message> to a datagrid and change the DataPropertyName.

However, if I happen to add more auto properties to this class, my datagrid starts to misbehave and sometimes I don’t just want some of the properties to the datagrid. Is there anyway I can bind the datagrid to only the values I selected DataPropertyName for?

Thanks.

  • 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-06-08T00:35:46+00:00Added an answer on June 8, 2026 at 12:35 am

    If you don’t want extra columns in your datagrid, why not start with your query, and don’t list them in the SELECT clause. This has the added benefit of reducing network traffic.

    Create multiple queries or views off the same table and use the right one at the right timefor your need. This is the “upstream” solution.

    Alternatively,

    When the AutoGenerateColumns property is set to true, each column
    automatically sets its DataPropertyName property to the name of a
    property or database column in the data source specified by the
    DataSource property. This binding can also be performed manually,
    which is useful when you want to display only a subset of the
    properties or database columns available in the data source. In such
    cases, set the AutoGenerateColumns property to false, and then
    manually add each DataGridViewColumn, setting the value of each
    DataPropertyName property to the properties or database columns in the
    data source that you want to display.

    That is straight from MSDN, you should have researched a little more thoroughly before posting this.
    http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumn.datapropertyname.aspx

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

Sidebar

Related Questions

I have an algorithm where I create two bi-dimensional arrays like this: TYPE TPtrMatrixLine
I want to create an object that acts as a specific class, such as
I have a view like this: CREATE VIEW MyView AS SELECT Column FROM Table
Sometimes I need to find some strings inside DB usually it is just host-name
Sometimes in case of a bug in our code, we usually ask the end
I have website, usually all looks fine but sometimes one div is on the
During development, I usually test ASP.Net applications using the Web Development Server (sometimes called
Sometimes i face the following problem : string txt = con.Request.Params[Par_name].ToString();//the original par value
Sometimes when using Visual Studio it displays a prompt with a filename: This file
Sometimes I heard people discussing about the start-up time for Java. It seems this

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.