Solved

Adding an Input Column to a DataGridView

Posted on 2009-05-09
2
344 Views
Last Modified: 2013-12-03
Hello,

I am developing a VB.NET forms application and I am trying to figure out the best way to approach a particular situation.  I have a form that will contain a DataGridView that will display a list of products which I would like to take inventory for.  I basically want to have a textbox at the end of the DGV that users will enter the amount of each product that they have in stock.  When they click a submit button at the bottom of the form, the program will go through and make an entry in my Inventory table for each product based on the values in the textbox.  What is the best way I should handle this?  Can I have just a blank textbox column where I can associate the value with the product that is on the same row?  Would I have to do some finageling with my Datasets in order to add a column I could store values in?  

TIA,

Mike
0
Comment
Question by:MClarkCCR
2 Comments
 
LVL 12

Accepted Solution

by:
needo_jee earned 500 total points
ID: 24346923
hi

if my understanding is not wrong then perhaps you want to add a column at the end of existing ones, this column will be used to collected input instead showing/displaying existing values? right? if so, I would use this way.

dim dt as dataTable
'fill data table

dt.columns.add("InputColumn")

myGridView.DataSource=dt.

Now it will display last column with empty text fields..


when use press save button.

you may get the newly entered values by iterating datatable rows

for each tr as DataRow in dt.Rows

dim inputValueForFirstRow as string=dr.Item("<last column>")
Next

-Thanks
0
 
LVL 3

Author Comment

by:MClarkCCR
ID: 24358126
needo_jee,

Thanks for your response.  This looks like it'll will probably be just what I needed.  I won't be able to test it out until later this evening, I will update you when I get the chance.

Mike
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now