473,471 Members | 4,616 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataBinding using a sequential file

I am new to vb.net and I am running into problems understanding
DataBinding and its concept. The only examples I find are always
talk about Web design, I only want to use this data on my
standalone computer. So my question is:

I have a sequential file that contains data and the data is structured.
is there a way to load this data into a DataGrid control?

If the answer is yes, then how do I accomplish this?

I am using vb.net the STANDARD version 2003.

Thanks

Tom
Nov 20 '05 #1
3 1517
Well.. Yes... you can... but coming from a flat file your going to struggle
a little.

In order for databinding to work within windows forms (particularly a grid)
a bindable class must implement ITypedList and IBindingList (for datagrid).
The minimum to do any binding is IList.

So.. the best approach for you is to build a class and derive IList for
starters just to get a feel of how it works (I think IList only has like 3
or 4 members you have to implement) and you can then bind that class. Now
this class will read in your sequential file and expose it to .NET in a
manner they both agree on (the IList Interface), and thats about it.

So.. your class reads in the file and implements IList... so you may have
something.

Public MyReadingClass Implements IList
...implementation and such
End Class

Public class myForm
inherits System.Windows.Forms.Form

public sub form_load(sender as object, e as system.eventargs) handles
mybase.load

dim myReader as new MyReadingClass

myDataGrid.DataSource = myReader
End Sub
End Class

This will give you a basic "list" (no column names, not multiple columns as
far as I know, just a list) but its a starting point for learning interfaces
and understanding IBindingList, and ITypedList.

Thats when it gets really fun (I'm serious, writing custom data binding
classes is fun!)

HTH,
CJ

"Tom McLaughlin" <tb***@cwnet.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
I am new to vb.net and I am running into problems understanding
DataBinding and its concept. The only examples I find are always
talk about Web design, I only want to use this data on my
standalone computer. So my question is:

I have a sequential file that contains data and the data is structured.
is there a way to load this data into a DataGrid control?

If the answer is yes, then how do I accomplish this?

I am using vb.net the STANDARD version 2003.

Thanks

Tom

Nov 20 '05 #2
Cor
Hi Tom,

A complete simple sample for your question that I have made a week ago.

The textfile is a csv file which has the comma delimiter in your culture
setting.

I hope this helps?

Cor
\\\drag a datagrid on your form and make a simple textfile
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
DataGrid1.DataSource = ds.Tables(0)
End Sub
//

I am new to vb.net and I am running into problems understanding
DataBinding and its concept. The only examples I find are always
talk about Web design, I only want to use this data on my
standalone computer. So my question is:

I have a sequential file that contains data and the data is structured.
is there a way to load this data into a DataGrid control?

If the answer is yes, then how do I accomplish this?

I am using vb.net the STANDARD version 2003.

Thanks

Tom

Nov 20 '05 #3
Ahh yes.. of course there is the "easy" way to do it too. =)
"Cor" <no*@non.com> wrote in message
news:Os*************@tk2msftngp13.phx.gbl...
Hi Tom,

A complete simple sample for your question that I have made a week ago.

The textfile is a csv file which has the comma delimiter in your culture
setting.

I hope this helps?

Cor
\\\drag a datagrid on your form and make a simple textfile
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
DataGrid1.DataSource = ds.Tables(0)
End Sub
//

I am new to vb.net and I am running into problems understanding
DataBinding and its concept. The only examples I find are always
talk about Web design, I only want to use this data on my
standalone computer. So my question is:

I have a sequential file that contains data and the data is structured.
is there a way to load this data into a DataGrid control?

If the answer is yes, then how do I accomplish this?

I am using vb.net the STANDARD version 2003.

Thanks

Tom


Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paolo Pignatelli | last post by:
I am trying to get an output/file like this (below) in an XML file (MyXmlFile.xml) (which I will use for a slide show) -- <gallery timer="3" order="sequential" fadetime="2" looping="yes"...
0
by: Jim dunn | last post by:
HI I am having problems with C# with regards to its compatibility with win32 API methods, I am trying to read from a windows CE comm port using C# and imported methods from coredll.dll, it seems...
2
by: Colin Robinson | last post by:
Help please I have an example class called Person with 2 public properties Firstname and Lastname, I cant create a textbox on an asp.net form bound to the Person.Firstname property Can...
4
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
4
by: Nathan Sokalski | last post by:
I have two databinding expressions (the first & last names from a DB) that I want to assign to the text property of a Label so that the result is LASTNAME,FIRSTNAME. At the moment, I have the...
9
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
9
by: Nathan Sokalski | last post by:
I have a very simple UserControl which contains an Image and a Label, which I use to display an image with a caption. I am using this control inside a DataList, setting the two Public variables...
11
by: Timofmars | last post by:
I'm try to Unload DB2 data from a table into a record sequential file on NT. I can an unload on Mainframe, but it doesn't seem to be an option in NT. In NT, all I can do is export/import. I can...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.