[Gambas-user] How to organize dependent lists
nando
nando_f at ...951...
Tue Feb 28 18:48:38 CET 2012
I would do it this way
1) I would make a class for data 1. If contains whatever PRIVATEs you wish
2) I would make an OBJECT[] which hold as many of the above class instances you need
3) I would make an OBJECT[] which hold as many of the above OBJECT[] as you need
item 1: OBJECT[] has two OBJECT[]s in it
item 1 a OBJECT[] has the next two items in it
data 1 aa <--class instance
data 1 ab <--class instance
item 1 b OBJECT[] has the next two items in it
data 1 ba <--class instance
data 1 bb <--class instance
..something like this...in your main startup
PUBLIC first AS NEW OBJECT[] 'This defines and creates the main OBJECT[]
PUBLIC second AS OBJECT[] 'This only defines the inner OBJECTs[]
...
DIM myData as Class_with_whatever_data_you_need
DIM second AS NEW OBJECT[] 'Create an instance of OBJECT[] for use as a second
first.add(second) 'This makes first[0].OBJECT[]
DIM second AS NEW OBJECT[] 'Create an another instance of OBJECT[] for use as another
second
first.add(second) 'This makes first[1].OBJECT[]
myData AS NEW Class_with_whatever_data_you_need 'create new instance of data
first[0][0].add(myData)
myData AS NEW Class_with_whatever_data_you_need 'create new instance of data
first[0][1].add(myData)
second = NEW OBJECT[]
first.add(second) 'this makes first[1] 'first.count=2
myData AS NEW Class_with_whatever_data_you_need 'create new instance of data
first[1][0].add(myData)
first[0] has OBJECT[] in it.
OBJECT[0] has a class instance
OBJECT[1] has a class instance
first[1] has OBJECT[] in it.
OBJECT[0] has a class instance
So,
first[1][0].whatever your class vars are.
-Fernando
---------- Original Message -----------
From: Rolf-Werner Eilert <eilert-sprachen at ...221...>
To: gambas-user at lists.sourceforge.net
Sent: Tue, 28 Feb 2012 18:18:18 +0100
Subject: [Gambas-user] How to organize dependent lists
> Hi folks,
>
> I would be interested in your opinions. In a project I've got two lists
> of data and further data which are mutually dependent, such as
>
> item 1:
> item 1 a
> data 1 aa
> data 1 ab
> item 1 b
> data 1 ba
> data 1 bb
>
> and so on, which could be seen like a tree or directory structure.
>
> Now my question is, how would YOU organize this internally? I mean, what
> kind of data structure would you prefer to be able to easily find your
> way through it? In the GUI, it looks like two ListBoxes and two TextBoxes:
>
> List1 List2 TextBox1
> TextBox2
>
> If you choose item1 in List1, List2 will show item1a and item1b. When
> you choose item1a, the Textboxes show data1aa and data1ab. If you choose
> item1b, the Textboxes show data1ba and data1bb.
>
> Of course, I could make a matrix of
>
> item1 item1a data1aa
> item1 item1a data1ab
> item1 item1b data1ba
> item1 item1b data1bb
>
> but how would my program EASILY find which data to show if the user
> clicks item1a for instance? Another idea was to leave out repetitions:
>
> item1 item1a data1aa
> data1ab
> item1b data1ba
> data1bb
>
> This shows the tree-like structure better, but is it a professional
> approach?
>
> Thanks for your ideas.
>
> Rolf
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------
More information about the User
mailing list