Solved

Insert data into a Data Grid View using Visual Studio 2005/C#

Posted on 2007-04-10
1
729 Views
Last Modified: 2013-11-26
I have a Windows program that I wrote in Visual Studio 2005 using C#.  It loops through a list of machine names and tries to contact them.  I would like to display the results in a grid format, but I can't figure out how to use a grid without a datasource.  I want a blank grid (except for headers), with a known number of columns that I can programmatically add rows to.  The data will not be retained when the program exits.  I've tried setting up a  Data Grid View with no data source and I can add columns in the designer, but I can't find a method that will allow me to create a new row.

0
Comment
Question by:nbtzlp3
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 125 total points
ID: 18884872
You can do a few things:

1) Create an in-memory DataTable to contain the data, and bind the DataGridView to the table.

2) Create an list of objects, using Generics, and bind the DataGridView to the list.

Bob
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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

22 Experts available now in Live!

Get 1:1 Help Now