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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:39:06+00:00 2026-06-03T20:39:06+00:00

My UI consist of a datagridview ( AutoCreateColumns= false ) bound to a list

  • 0

My UI consist of a datagridview (AutoCreateColumns= false) bound to a list of my business objects. Let’s assume my Object contains 2 columns – Price and Quantity – and I’d want to add a new column in my grid – Total – which value will be calculated – Price*Quantity, BUT with no modification of my Business object.

Is it possible?

  • 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-03T20:39:09+00:00Added an answer on June 3, 2026 at 8:39 pm

    Yes.

    You can add unbound columns to a grid programmatically, and you populate the column’s cells either using events.

    There are two primary ways to populate the contents of unbound columns: handling the RowsAdded event or handling the CellFormatting event. If the grid is editable CellValueChanged also needs to be handled. The CellFormatting event can also be used to transform values as they are presented in a cell to something different than the value that is actually stored in the data that sits behind the grid.

    Code Sample –

    private void OnCellFormatting(object sender,
       DataGridViewCellFormattingEventArgs e)
    {
    
        if (e.ColumnIndex == grid.Columns["Unbound"].Index)
        {
           e.FormattingApplied = true;
           DataGridViewRow row = grid.Rows[e.RowIndex];
           e.Value = string.Format("{0} : {1}",
              row.Cells["SomeColumn1"].Value,
              row.Cells["SomeColumn2"].Value);
        }
    }
    
    private void OnRowsAdded(object sender,
       DataGridViewRowsAddedEventArgs e)
    {
    
       for (int i = 0; i < e.RowCount; i++)
       {
          DataGridViewRow row = grid.Rows[e.RowIndex + i];
          row.Cells["Unbound"].Value = string.Format("{0} : {1}",
             row.Cells["SomeColumn1"].Value,
             row.Cells["SomeColumn2"].Value);
        }
    }
    

    More in detail – http://www.informit.com/articles/article.aspx?p=446453&seqNum=5

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

Sidebar

Related Questions

I have two list that consist out of the same object. I want to
I have two arraylists that consist of the datetime objects and merging both the
I currently have a database that consist of many linked objects. Simplified with less
My solution file contains many projects which consist of many template files and I
I have the following business object: public class MyObject { // Some public properties
My web pages consist of two parts, let's say top and bottom (except header
My datagrid consist of 3 columns. If the user edit the 1st cell in
Among the elements that consist my xml, I have got element let's call it
i have table consist of columns : id,name,job and i have row stored with
My table consist of columns StartTime and EndTime with datetime datatype. I have calculated

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.