Solved

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

Posted on 2007-04-10
1
730 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

831 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