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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:32:49+00:00 2026-06-13T15:32:49+00:00

Is there a way to add a column footer in a datagridview which is

  • 0

Is there a way to add a column footer in a datagridview which is not databound? I am using it to take user input for adding inventory. Currently I am using a label to display the total, but I want to change it to footer if 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-13T15:32:50+00:00Added an answer on June 13, 2026 at 3:32 pm

    I ran into the same problem previously and after a long search I realised;

    1. Winform Datagridview do not support adding footer to it.

    2. I tried adding an extra row that could hold the summary but still did not work out fine.

    3. You can create a user control that has two grids and with the lower grid holding the summary.

    Solution–
    enter image description here

    1. My solution that used data binding.(1)-I Create an abstract object Item with (Name, Cost) properties.(2)-I Create a Concrete item i.e ConcItem that inherit Item(3)-I create a footer item i.e FooterItem that also inherits Item(4)-A collection of Items i.e ItemList where you instantiate the footer item.(5) Finally, just before you do data binding call the method that adds the footer item.

      public abstract class Item
      {
        public virtual string Name { get; set; }
        public virtual int Cost { get; set; }
      }
      public  class ConcItem:Item
      {
        public override string Name { get; set; }
        public override int Cost { get; set; }        
      }
      public  class FooterItem:Item 
      {
        public override string Name { get { return "Total"; } }
        public override int Cost { get; set; }
      }
      public class ItemList : List<Item>
      {
        private Item _footer;
      
        public void SetFooter()
        {
          _footer = new FooterItem();            
          foreach (var item in this)
          {
            _footer.Cost += item.Cost;              
          }
          this.Add(_footer);
        }
      }
      
      
      public partial class Form1 : Form
      {
        Item _item;
        ItemList _itemList;
        public Form1()
        {
          InitializeComponent();
          dgv.DataBindingComplete += dgv_DataBindingComplete;
          _itemList = new ItemList();
      
          SetSampleData();
        }
        private void SetSampleData()
        {
          _item = new ConcItem();
          _item.Name = "Book";
          _item.Cost = 250;
          _itemList.Add(_item);
      
          _item = new ConcItem();
          _item.Name = "Table";
          _item.Cost = 500;
          _itemList.Add(_item);
      
          _item = new ConcItem();
          _item.Name = "PC";
          _item.Cost = 700;
          _itemList.Add(_item);
      
          dgv.DataSource = null;
          _itemList.SetFooter();  //Add the footer item b4  data binding
          dgv.DataSource = _itemList;
        }
        void dgv_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
          //If you want to do some formating on the footer row
          int rowIndex = dgv.Rows.GetLastRow(DataGridViewElementStates.Visible);
          if (rowIndex <= 0)
          {
            return;
          }
          dgv.Rows[rowIndex].DefaultCellStyle.BackColor = Color.Red;
          dgv.Rows[rowIndex].DefaultCellStyle.SelectionBackColor = Color.Red;        
          dgv.Rows[rowIndex].DefaultCellStyle.Font = new Font("Microsoft Sans Serif", 12f,    FontStyle.Bold);
        }
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to add a not null type column to a Postgresql
Is there a way you can add a column to the Details view of
Is there a way to add a custom column to DataTable jQuery plugin, such
Is there a way to add a progress bar in the footer (fbar) of
Is there any way I can add a column based on another column's attribute?
Is there a way to add a customize DatagridviewRow using c#? Ive made a
Is there any way I can add a column to a table but I
Is there a way in a derby database to add a column after another
are there any way to add new column to the table with JQuery plugin
Is there a way to add a column to the search result in outlook,

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.