Edwin
Sorry, missed the bit about it being in VB.
Here goes again:
A) using UniXML
Private ds As DataSet
Private Function showDict(ByVal fileName As String, ByVal sess As
UniSession, ByVal dg As DataGridView) As Boolean
Dim xml As UniXML = sess.CreateUniXML()
xml.GenerateXML("SORT DICT " + fileName)
ds = xml.GetDataSet()
dg.AutoGenerateColumns = True
dg.DataSource = ds.Tables(0)
Return True
End Function
B) Using a List(Of DictItem)
Private list As List(Of DictItem) = New List(Of DictItem)
Private Function showDict2(ByVal fileName As String, ByVal sess As
UniSession, ByVal dg As DataGridView) As Boolean
Dim dict As UniFile = sess.CreateUniFile("DICT " + fileName)
Dim sel As UniSelectList = sess.CreateUniSelectList(0)
sel.Select(dict)
Do While sel.LastRecordRead = False
Dim id As String = sel.Next
If String.IsNullOrEmpty(id) = False Then
Dim dictRec As UniDynArray = dict.Read(id)
Dim item As DictItem = New DictItem()
item.Id = id
item.Type = dictRec.Extract(1).StringValue
' etc
list.Add(item)
End If
Loop
dg.DataSource = list
Return True
End Function
Where:
Class DictItem
Private _id As String = String.Empty
Private _type As String = String.Empty
Private _fno As Int32 = 0
(etc)
Public Property Id()
Get
Return _id
End Get
Set(ByVal value)
_id = value
End Set
End Property
Public Property Type()
Get
Return _type
End Get
Set(ByVal value)
_type = value
End Set
End Property
(etc)
End Class
Brian
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Brian Leach
> Sent: 14 July 2009 12:30
> To: 'U2 Users List'
> Subject: Re: [U2] list DICT uniObjects
>
> Edwin
>
> Two ways to do this:
>
> The quick/dirty and frankly not very good way is to use UniXML:
>
> private DataSet ds;
> private Boolean showDict(String fileName, UniSession
> sess, DataGridView dg) {
> UniXML xml = sess.CreateUniXML();
> xml.GenerateXML("SORT DICT " + fileName);
> ds = xml.GetDataSet();
> dg.AutoGenerateColumns = true;
> dg.DataSource = ds.Tables[0];
> return true;
> }
>
> The better way is create a DictItem class to hold the
> dictionary elements, e.g.
>
> class DictItem{
> private String _id = String.Empty;
> private String _type = String.Empty;
> private Int32 _fno = 0;
> (etc)
> public String Id{
> get { return _id; }
> set { _id = value; }
> }
> (etc)
> }
>
> You can then populate a List<DictItem> by reading each one
> from the dictionary, and set that as the data source for the grid.
>
> private List<DictItem> list = new List<DictItem>();
> private Boolean showDict(String fileName, UniSession
> sess, DataGridView dg){
>
>
> UniFile dict = sess.CreateUniFile("DICT " + fileName);
> UniSelectList sel = sess.CreateUniSelectList(0);
> sel.Select(dict);
> while (sel.LastRecordRead == false) {
> String id = sel.Next();
> if (String.IsNullOrEmpty(id) == false) {
> UniDynArray dictRec = dict.Read(id);
> DictItem item = new DictItem();
> item.Id = id;
> item.Type = dictRec.Extract(1).StringValue;
> // etc
> list.Add(item);
> }
> }
>
> dg.DataSource = list;
> return true;
> }
>
>
> Brian
>
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Edwin
> > Maluleke
> > Sent: 14 July 2009 10:48
> > To: [email protected]
> > Subject: [U2] list DICT uniObjects
> >
> > Hi,
> >
> > I am trying to read and list the dictionary of a file on a dataGrid
> > vb.net express 2008. I am using the uniObjects framework/library. I
> > just can't seem to find my way round it.
> > Please help
> >
> > _______________________________________________
> > U2-Users mailing list
> > [email protected]
> > http://listserver.u2ug.org/mailman/listinfo/u2-users
> >
>
> _______________________________________________
> U2-Users mailing list
> [email protected]
> http://listserver.u2ug.org/mailman/listinfo/u2-users
>
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users