Solved

adding data to a DGV

Posted on 2014-02-20
1
245 Views
Last Modified: 2014-02-20
hi - I have a datagridview that is linked to a datatable, where every column in the DGV is bound to a field in the datatable. I've added a column that I want to fill in programmatically, but the data isn't being displayed. I suspect it's because the rest of the DGV is data bound. how would I go about filling in the column with programmatically generated data? the couple lines below show where the data is coming from:

won't let me paste.
0
Comment
Question by:jdcoburn
1 Comment
 
LVL 24

Accepted Solution

by:
mankowitz earned 500 total points
ID: 39874198
you have to modify the underlying data structure before you bind the dgv to the datatable.

For example

DataTable dt = new DataTable("Customers");

workTable.Columns.Add("FirstName", typeof(String));
workTable.Columns.Add("LastName", typeof(String));
workTable.Columns.Add("FullName", typeof(String));

workTable.Columns["FullName"].Expression = "FirstName + LastName";

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

939 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

10 Experts available now in Live!

Get 1:1 Help Now