469,623 Members | 1,525 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

lightweight grid

G'day all,
I want to load comma sep text files and display it in a grid. I'd like
something simple and lightweight. Don't need to edit it in grid, I could
do that in textboxes if required.
tia
build
Jul 17 '05 #1
2 2270
read the file with a streamreader and add the content to a table row.bind the table to a grid. hope this helps

phil
"build" <bu************@datafast.net.au> wrote in message news:41******@news.alphalink.com.au...
G'day all,
I want to load comma sep text files and display it in a grid. I'd like
something simple and lightweight. Don't need to edit it in grid, I could
do that in textboxes if required.
tia
build
Jul 17 '05 #2
> I want to load comma sep text files and display it in a grid. I'd like
something simple and lightweight. Don't need to edit it in grid, I could do that in textboxes if required.


If you use an MSFlexGrid control, you can load your CSV text files via
the Clip property (which requires you to select enough cells to house
all the data... for what you want, simply select the entire grid). Place
a MSFlexGrid on your form and give this code a try...

Rick - MVP

Dim FileNum As Integer
Dim TotalFile As String
FileNum = FreeFile
' Reads the entire file into memory all at once
Open "c:\SomeDirectory\TextFile.txt" For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum, , TotalFile
Close #FileNum
TotalFile = Replace(Replace(TotalFile, vbNewLine, vbCr), ",", vbTab)
With MSFlexGrid1
' Assuming user can't select a cell
' .HighLight = flexHighlightNever
' Select every cell
.Row = .FixedRows
.Col = .FixedCols
.RowSel = .Rows - 1
.ColSel = .Cols - 1
' Fill them
.Clip = TotalFile
' Get rid of selection and pick cell to be active
.Row = 1
.Col = 1
End With

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Jeremy Hylton | last post: by
1 post views Thread by Guinness Mann | last post: by
reply views Thread by tjr7933 | last post: by
reply views Thread by Andrew Fedoniouk | last post: by
2 posts views Thread by Martin Halle | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.