Solved

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

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

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