True DBGrid ExportToDelimitedFile missing Header record

True DBGrid 6.0
VB 6.0

I am currently using the ExportToDelimitedFile command as follows.

Grid.ExportToDelimitedFile sConvFileName, , ","

I would like to have the headers or as they call it the captions exported to the file also. Can this be done with True DBgrid? Is there another command that supports the export of the header record.

Thanks
DarebearAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aeklundCommented:
I don't know much about this 3rd party control, but here is a solution that will work:

  'Call your export function
  Grid.ExportToDelimitedFile sConvFileName, , ","
 
  'Now use this to add the Headers (to a new file)
  Dim sLine As String
  Open sConvFileName For Input As #1
 
  'Write Headers
  Open sConvFileName & "-headers.txt" For Output As #2
    Dim i As Integer
    For i = 0 To Grid.Columns.Count - 1
      If i = 0 Then
        sLine = Chr(34) & Grid.Columns(i).Caption & Chr(34)
      Else
        sLine = sLine & "," & Chr(34) & Grid.Columns(i).Caption & Chr(34)
      End If
    Next
    Print #2, sLine
   
    'Write contents of original file
    Do Until EOF(1)
      Line Input #1, sLine
      Print #2, sLine
    Loop
  Close
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DarebearAuthor Commented:
The above solution works and I will award the points if nobody can provide the true dbgrid with in a day or two.

Thank you
0
DarebearAuthor Commented:
The above solution works and I will award the points if nobody can provide the true dbgrid with in a day or two.

Thank you
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

aeklundCommented:
Great... I downloaded the help for the true dbgrig 8.0 (apex) and I don't see anywhere in the documentation on how to export the headers as the first row of your exported file.
0
DarebearAuthor Commented:
The points are all yours.
0
aeklundCommented:
Glad to help.. thx for the points
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.