Solved

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

Posted on 2006-11-13
1
357 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

705 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

15 Experts available now in Live!

Get 1:1 Help Now