Solved

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

Posted on 2006-11-13
1
389 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
1 Comment
 
LVL 10

Accepted Solution

by:
gangwisch earned 500 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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