Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to read DataGridView to String Variable seperating each field with a Tab character

Posted on 2006-11-13
1
Medium Priority
?
408 Views
Last Modified: 2008-01-09
I am using the DataGridView to allow users to enter a variable amount of information from an Access DB.  At the end of the application it sends an e-mail with other form data but I would also like the contents of the data grid to be included in the e-mail.  The e-mail is working with form field based content but the dataset/datagrid view is new.

How would you store the contents of the DataGridView into a String variable with the following formatting?

- Each field value seperated with a tab
- If the DataGridView dataset has no rows then the value of the entire string variable should be N/A.

Example (Dataset has data):
Field1      Field2      Field3      Field4
Field1      Field2      Field3      Field4
Field1      Field2      Field3      Field4
Field1      Field2      Field3      Field4

Example (Dataset has no data):
N/A


The Datagridview is named datagridTransport
0
Comment
Question by:endrec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
gangwisch earned 2000 total points
ID: 17931912
dim EmailText as string="Hello this is a test email" & vbcrlf
for r as integer=0 to datagridview1.rows.count-1
dim CurRowStr as string=""
for c as integer=0 to datagridview1.columns.count-1
CurRowStr &= datagridview1.item(c,r).value & chr(9)
next
EmailText &=CurRowStr & vbcrlf
next
if datagridview1.rows.count=0 then
EmailText &="N/A"
end if
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

604 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