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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:48:48+00:00 2026-06-18T04:48:48+00:00

I have a training project at my new job and a really small but

  • 0

I have a training project at my new job and a really small but crucial setback.

I have a datagridview control bound to a dataset read from an xml file. It has 3 columns: item, price, calories. I am supposed to calculate the average values for price and calories and place them in the row below the entries that are read in from the xml. This works fine, except that when I fill the bottom row with the averages, the row remains uncommitted and when a user selects the row, the values disappear. If you manually type an entry into the row, it commits as expected and a new uncommitted row appears. How do I get the same behavior from calculated entries placed programmatically on the bottom row? Since the dgview is databound I can’t do dgview.rows.add or anything like that.
My goes basically goes like this:

Private Sub PopulateDGView(ByVal sFilePath As String)
Dim dgview As New DataGridView
Dim ds As New dataset
Dim dPriceAvg As Double = 0
Dim dCaloriesAvg As Double = 0
ds.readxml(sFilePath)

dgview.datasource = ds
dgview.DataMember = "food"

'[Here I loop through the rows, sum the values and divide by the number of rows to get
 'the average values for the columns then write the following]

dgview.Rows(dgview.Rows.GetLastRow(DataGridViewElementStates.Displayed)). _
Cells("Item").Value = "Average"
dgview.Rows(dgview.Rows.GetLastRow(DataGridViewElementStates.Displayed)). _
Cells("Price").Value = dPriceAvg.ToString
dgview.Rows(dgview.Rows.GetLastRow(DataGridViewElementStates.Displayed)). _
Cells("Calories").Value = dCaloriesAvg.ToString
End Sub

This puts the average values on the uncommitted row, which is the only available unfilled row. I would think that would cause a new row to appear, but it doesn’t. The average row remains uncommitted and as I mentioned all data on the row disappears when the row is selected. How can I force the row to commit and show a new uncommitted row below it? Just as some additional information, I cannot use the microsoft.visualbasic library. Any assistance is appreciated. Thanks in advance.

  • 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-18T04:48:50+00:00Added an answer on June 18, 2026 at 4:48 am

    Right, the reason you databind something is because you want changes to that item to appear in the design view and/or to be able to manually add data to the source.

    So instead of adding stuff programmatically to the item that display the dataset, you add the data to the dataset which then displays it.

    ds.tables(0).Rows.Add()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I create a new android project (following these steps: http://developer.android.com/training/basics/firstapp/creating-project.html ) I automatically
I have a new mobile application I need to get out the door but
Greetings, all. I'm working on a training project; I have a page for user
I'm trying to develop a small plugin-based training calculator as a home project (designed
http://developer.android.com/training/basics/firstapp/building-ui.html I have been following this tutorial, but I have two errors, both R
I have an AI project, which uses a Backpropagation neural network. It is training
I'm training with Azure environment and I have some trouble with the object CloudDriver
I'm training code problems like UvA and I have this one in which I
I have very little experience with ASP.NET and I am doing some self-training before
I have 2 data frames. One is training data ( pubs1 ), the other

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.