Solved

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

Posted on 2007-04-10
1
728 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

744 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

17 Experts available now in Live!

Get 1:1 Help Now